提交 ffece161 编写于 作者: P peng-yongsheng

Indicator analysis test successfully.

上级 66df7e6f
......@@ -51,11 +51,6 @@
<artifactId>library-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-network</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-datacarrier</artifactId>
......
......@@ -20,6 +20,10 @@ package org.apache.skywalking.oap.server.core.analysis;
import java.util.*;
import org.apache.skywalking.oap.server.core.analysis.generated.endpoint.EndpointDispatcher;
import org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancejvmcpu.ServiceInstanceJVMCPUDispatcher;
import org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancejvmgc.ServiceInstanceJVMGCDispatcher;
import org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemory.ServiceInstanceJVMMemoryDispatcher;
import org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemorypool.ServiceInstanceJVMMemoryPoolDispatcher;
import org.apache.skywalking.oap.server.core.source.Scope;
import org.slf4j.*;
......@@ -35,6 +39,11 @@ public class DispatcherManager {
public DispatcherManager() {
this.dispatcherMap = new HashMap<>();
this.dispatcherMap.put(Scope.Endpoint, new EndpointDispatcher());
this.dispatcherMap.put(Scope.ServiceInstanceJVMCPU, new ServiceInstanceJVMCPUDispatcher());
this.dispatcherMap.put(Scope.ServiceInstanceJVMGC, new ServiceInstanceJVMGCDispatcher());
this.dispatcherMap.put(Scope.ServiceInstanceJVMMemory, new ServiceInstanceJVMMemoryDispatcher());
this.dispatcherMap.put(Scope.ServiceInstanceJVMMemoryPool, new ServiceInstanceJVMMemoryPoolDispatcher());
}
public SourceDispatcher getDispatcher(Scope scope) {
......
......@@ -20,12 +20,13 @@ package org.apache.skywalking.oap.server.core.analysis.generated.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
/**
* This class is auto generated. Please don't change this class manually.
......@@ -35,14 +36,16 @@ import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
@IndicatorType
@StreamData
@StorageEntity(name = "endpoint_avg", builder = EndpointAvgIndicator.Builder.class)
public class EndpointAvgIndicator extends AvgIndicator {
public class EndpointAvgIndicator extends LongAvgIndicator {
@Setter @Getter @Column(columnName = "id") private int id;
@Setter @Getter @Column(columnName = "service_id") private int serviceId;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
return String.valueOf(id);
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + String.valueOf(id);
return splitJointId;
}
@Override public int hashCode() {
......@@ -52,7 +55,6 @@ public class EndpointAvgIndicator extends AvgIndicator {
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
......@@ -70,7 +72,6 @@ public class EndpointAvgIndicator extends AvgIndicator {
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
......@@ -116,13 +117,13 @@ public class EndpointAvgIndicator extends AvgIndicator {
@Override public EndpointAvgIndicator map2Data(Map<String, Object> dbMap) {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setId((int)dbMap.get("id"));
indicator.setServiceId((int)dbMap.get("service_id"));
indicator.setServiceInstanceId((int)dbMap.get("service_instance_id"));
indicator.setSummation((long)dbMap.get("summation"));
indicator.setCount((int)dbMap.get("count"));
indicator.setValue((long)dbMap.get("value"));
indicator.setTimeBucket((long)dbMap.get("time_bucket"));
indicator.setId(((Number)dbMap.get("id")).intValue());
indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
......
......@@ -29,7 +29,6 @@ import org.apache.skywalking.oap.server.core.source.Endpoint;
*/
public class EndpointDispatcher implements SourceDispatcher<Endpoint> {
@Override public void dispatch(Endpoint source) {
doEndpointAvg(source);
doEndpointPercent(source);
......@@ -45,6 +44,7 @@ public class EndpointDispatcher implements SourceDispatcher<Endpoint> {
indicator.combine(source.getLatency(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointPercent(Endpoint source) {
EndpointPercentIndicator indicator = new EndpointPercentIndicator();
......@@ -55,4 +55,5 @@ public class EndpointDispatcher implements SourceDispatcher<Endpoint> {
indicator.combine(new org.apache.skywalking.oap.server.core.analysis.indicator.expression.BooleanBinaryMatch(), source.isStatus(), true);
IndicatorProcess.INSTANCE.in(indicator);
}
}
......@@ -20,12 +20,13 @@ package org.apache.skywalking.oap.server.core.analysis.generated.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.PercentIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
/**
* This class is auto generated. Please don't change this class manually.
......@@ -42,7 +43,9 @@ public class EndpointPercentIndicator extends PercentIndicator {
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
return String.valueOf(id);
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + String.valueOf(id);
return splitJointId;
}
@Override public int hashCode() {
......@@ -52,7 +55,6 @@ public class EndpointPercentIndicator extends PercentIndicator {
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
......@@ -70,7 +72,6 @@ public class EndpointPercentIndicator extends PercentIndicator {
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
......@@ -116,13 +117,13 @@ public class EndpointPercentIndicator extends PercentIndicator {
@Override public EndpointPercentIndicator map2Data(Map<String, Object> dbMap) {
EndpointPercentIndicator indicator = new EndpointPercentIndicator();
indicator.setId((int)dbMap.get("id"));
indicator.setServiceId((int)dbMap.get("service_id"));
indicator.setServiceInstanceId((int)dbMap.get("service_instance_id"));
indicator.setTotal((long)dbMap.get("total"));
indicator.setPercentage((int)dbMap.get("percentage"));
indicator.setMatch((long)dbMap.get("match"));
indicator.setTimeBucket((long)dbMap.get("time_bucket"));
indicator.setId(((Number)dbMap.get("id")).intValue());
indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setTotal(((Number)dbMap.get("total")).longValue());
indicator.setPercentage(((Number)dbMap.get("percentage")).intValue());
indicator.setMatch(((Number)dbMap.get("match")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
......
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmcpu;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "instance_jvm_cpu", builder = InstanceJvmCpuIndicator.Builder.class)
public class InstanceJvmCpuIndicator extends DoubleAvgIndicator {
@Setter @Getter @Column(columnName = "id") private int id;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + String.valueOf(id);
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + id;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
InstanceJvmCpuIndicator indicator = (InstanceJvmCpuIndicator)obj;
if (id != indicator.id)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.setDataLongs(0, getTimeBucket());
remoteBuilder.setDataDoubles(0, getSummation());
remoteBuilder.setDataDoubles(1, getValue());
remoteBuilder.setDataIntegers(0, getId());
remoteBuilder.setDataIntegers(1, getServiceInstanceId());
remoteBuilder.setDataIntegers(2, getCount());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setSummation(remoteData.getDataDoubles(0));
setValue(remoteData.getDataDoubles(1));
setId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
setCount(remoteData.getDataIntegers(2));
}
public static class Builder implements StorageBuilder<InstanceJvmCpuIndicator> {
@Override public Map<String, Object> data2Map(InstanceJvmCpuIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("id", storageData.getId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("summation", storageData.getSummation());
map.put("count", storageData.getCount());
map.put("value", storageData.getValue());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public InstanceJvmCpuIndicator map2Data(Map<String, Object> dbMap) {
InstanceJvmCpuIndicator indicator = new InstanceJvmCpuIndicator();
indicator.setId(((Number)dbMap.get("id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setSummation(((Number)dbMap.get("summation")).doubleValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).doubleValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmcpu;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMCPU;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMCPUDispatcher implements SourceDispatcher<ServiceInstanceJVMCPU> {
@Override public void dispatch(ServiceInstanceJVMCPU source) {
doInstanceJvmCpu(source);
}
private void doInstanceJvmCpu(ServiceInstanceJVMCPU source) {
InstanceJvmCpuIndicator indicator = new InstanceJvmCpuIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setId(source.getId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getUsePercent(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmgc;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "instance_jvm_gc_time", builder = InstanceJvmGcTimeIndicator.Builder.class)
public class InstanceJvmGcTimeIndicator extends LongAvgIndicator {
@Setter @Getter @Column(columnName = "id") private int id;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + String.valueOf(id);
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + id;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
InstanceJvmGcTimeIndicator indicator = (InstanceJvmGcTimeIndicator)obj;
if (id != indicator.id)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.setDataLongs(0, getSummation());
remoteBuilder.setDataLongs(1, getValue());
remoteBuilder.setDataLongs(2, getTimeBucket());
remoteBuilder.setDataIntegers(0, getId());
remoteBuilder.setDataIntegers(1, getServiceInstanceId());
remoteBuilder.setDataIntegers(2, getCount());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setSummation(remoteData.getDataLongs(0));
setValue(remoteData.getDataLongs(1));
setTimeBucket(remoteData.getDataLongs(2));
setId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
setCount(remoteData.getDataIntegers(2));
}
public static class Builder implements StorageBuilder<InstanceJvmGcTimeIndicator> {
@Override public Map<String, Object> data2Map(InstanceJvmGcTimeIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("id", storageData.getId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("summation", storageData.getSummation());
map.put("count", storageData.getCount());
map.put("value", storageData.getValue());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public InstanceJvmGcTimeIndicator map2Data(Map<String, Object> dbMap) {
InstanceJvmGcTimeIndicator indicator = new InstanceJvmGcTimeIndicator();
indicator.setId(((Number)dbMap.get("id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmgc;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMGC;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMGCDispatcher implements SourceDispatcher<ServiceInstanceJVMGC> {
@Override public void dispatch(ServiceInstanceJVMGC source) {
doInstanceJvmGcTime(source);
}
private void doInstanceJvmGcTime(ServiceInstanceJVMGC source) {
InstanceJvmGcTimeIndicator indicator = new InstanceJvmGcTimeIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setId(source.getId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getTime(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemory;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "instance_jvm_memory_max", builder = InstanceJvmMemoryMaxIndicator.Builder.class)
public class InstanceJvmMemoryMaxIndicator extends LongAvgIndicator {
@Setter @Getter @Column(columnName = "id") private int id;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + String.valueOf(id);
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + id;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
InstanceJvmMemoryMaxIndicator indicator = (InstanceJvmMemoryMaxIndicator)obj;
if (id != indicator.id)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.setDataLongs(0, getSummation());
remoteBuilder.setDataLongs(1, getValue());
remoteBuilder.setDataLongs(2, getTimeBucket());
remoteBuilder.setDataIntegers(0, getId());
remoteBuilder.setDataIntegers(1, getServiceInstanceId());
remoteBuilder.setDataIntegers(2, getCount());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setSummation(remoteData.getDataLongs(0));
setValue(remoteData.getDataLongs(1));
setTimeBucket(remoteData.getDataLongs(2));
setId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
setCount(remoteData.getDataIntegers(2));
}
public static class Builder implements StorageBuilder<InstanceJvmMemoryMaxIndicator> {
@Override public Map<String, Object> data2Map(InstanceJvmMemoryMaxIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("id", storageData.getId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("summation", storageData.getSummation());
map.put("count", storageData.getCount());
map.put("value", storageData.getValue());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public InstanceJvmMemoryMaxIndicator map2Data(Map<String, Object> dbMap) {
InstanceJvmMemoryMaxIndicator indicator = new InstanceJvmMemoryMaxIndicator();
indicator.setId(((Number)dbMap.get("id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemory;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMMemory;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMMemoryDispatcher implements SourceDispatcher<ServiceInstanceJVMMemory> {
@Override public void dispatch(ServiceInstanceJVMMemory source) {
doInstanceJvmMemoryMax(source);
}
private void doInstanceJvmMemoryMax(ServiceInstanceJVMMemory source) {
InstanceJvmMemoryMaxIndicator indicator = new InstanceJvmMemoryMaxIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setId(source.getId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getMax(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemorypool;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "instance_jvm_memory_pool_max", builder = InstanceJvmMemoryPoolMaxIndicator.Builder.class)
public class InstanceJvmMemoryPoolMaxIndicator extends LongAvgIndicator {
@Setter @Getter @Column(columnName = "id") private int id;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + String.valueOf(id);
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + id;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
InstanceJvmMemoryPoolMaxIndicator indicator = (InstanceJvmMemoryPoolMaxIndicator)obj;
if (id != indicator.id)
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.setDataLongs(0, getSummation());
remoteBuilder.setDataLongs(1, getValue());
remoteBuilder.setDataLongs(2, getTimeBucket());
remoteBuilder.setDataIntegers(0, getId());
remoteBuilder.setDataIntegers(1, getServiceInstanceId());
remoteBuilder.setDataIntegers(2, getCount());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setSummation(remoteData.getDataLongs(0));
setValue(remoteData.getDataLongs(1));
setTimeBucket(remoteData.getDataLongs(2));
setId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
setCount(remoteData.getDataIntegers(2));
}
public static class Builder implements StorageBuilder<InstanceJvmMemoryPoolMaxIndicator> {
@Override public Map<String, Object> data2Map(InstanceJvmMemoryPoolMaxIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("id", storageData.getId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("summation", storageData.getSummation());
map.put("count", storageData.getCount());
map.put("value", storageData.getValue());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public InstanceJvmMemoryPoolMaxIndicator map2Data(Map<String, Object> dbMap) {
InstanceJvmMemoryPoolMaxIndicator indicator = new InstanceJvmMemoryPoolMaxIndicator();
indicator.setId(((Number)dbMap.get("id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemorypool;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMMemoryPool;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMMemoryPoolDispatcher implements SourceDispatcher<ServiceInstanceJVMMemoryPool> {
@Override public void dispatch(ServiceInstanceJVMMemoryPool source) {
doInstanceJvmMemoryPoolMax(source);
}
private void doInstanceJvmMemoryPoolMax(ServiceInstanceJVMMemoryPool source) {
InstanceJvmMemoryPoolMaxIndicator indicator = new InstanceJvmMemoryPoolMaxIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setId(source.getId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getMax(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
}
/*
* 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.skywalking.oap.server.core.analysis.indicator;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author peng-yongsheng
*/
@IndicatorOperator
public abstract class DoubleAvgIndicator extends Indicator {
protected static final String SUMMATION = "summation";
protected static final String COUNT = "count";
protected static final String VALUE = "value";
@Getter @Setter @Column(columnName = SUMMATION) private double summation;
@Getter @Setter @Column(columnName = COUNT) private int count;
@Getter @Setter @Column(columnName = VALUE) private double value;
@Entrance
public final void combine(@SourceFrom double summation, @ConstOne int count) {
this.summation += summation;
this.count += count;
}
@Override public final void combine(Indicator indicator) {
DoubleAvgIndicator avgIndicator = (DoubleAvgIndicator)indicator;
combine(avgIndicator.summation, avgIndicator.count);
}
@Override public final void calculate() {
this.value = this.summation / this.count;
}
}
......@@ -35,4 +35,6 @@ public abstract class Indicator extends StreamData implements StorageData {
public abstract String id();
public abstract void combine(Indicator indicator);
public abstract void calculate();
}
......@@ -26,7 +26,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
* @author peng-yongsheng
*/
@IndicatorOperator
public abstract class AvgIndicator extends Indicator {
public abstract class LongAvgIndicator extends Indicator {
protected static final String SUMMATION = "summation";
protected static final String COUNT = "count";
......@@ -43,7 +43,11 @@ public abstract class AvgIndicator extends Indicator {
}
@Override public final void combine(Indicator indicator) {
AvgIndicator avgIndicator = (AvgIndicator)indicator;
LongAvgIndicator avgIndicator = (LongAvgIndicator)indicator;
combine(avgIndicator.summation, avgIndicator.count);
}
@Override public final void calculate() {
this.value = this.summation / this.count;
}
}
......@@ -18,13 +18,8 @@
package org.apache.skywalking.oap.server.core.analysis.indicator;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Entrance;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Expression;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.ExpressionArg0;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.ExpressionArg1;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorOperator;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.BooleanBinaryMatch;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
......@@ -56,4 +51,8 @@ public abstract class PercentIndicator extends Indicator {
total += ((PercentIndicator)indicator).total;
match += ((PercentIndicator)indicator).match;
}
@Override public void calculate() {
percentage = (int)(match / total);
}
}
/*
* 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.skywalking.oap.server.core.source;
/**
* @author peng-yongsheng
*/
public enum DetectPoint {
CLIENT, SERVER, PROXY
}
......@@ -19,7 +19,6 @@
package org.apache.skywalking.oap.server.core.source;
import lombok.*;
import org.apache.skywalking.apm.network.language.agent.SpanLayer;
import org.apache.skywalking.oap.server.core.source.annotation.SourceType;
/**
......@@ -40,5 +39,5 @@ public class Endpoint extends Source {
@Getter @Setter private int latency;
@Getter @Setter private boolean status;
@Getter @Setter private int responseCode;
@Getter @Setter private SpanLayer type;
@Getter @Setter private RequestType type;
}
......@@ -19,7 +19,6 @@
package org.apache.skywalking.oap.server.core.source;
import lombok.*;
import org.apache.skywalking.apm.network.language.agent.*;
/**
* @author peng-yongsheng
......@@ -37,7 +36,7 @@ public class EndpointRelation extends Source {
@Getter @Setter private int rpcLatency;
@Getter @Setter private boolean status;
@Getter @Setter private int responseCode;
@Getter @Setter private SpanLayer type;
@Getter @Setter private SpanType detectPoint;
@Getter @Setter private RequestType type;
@Getter @Setter private DetectPoint detectPoint;
}
/*
* 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.skywalking.oap.server.core.source;
/**
* @author peng-yongsheng
*/
public enum GCPhrase {
NEW, OLD
}
/*
* 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.skywalking.oap.server.core.source;
/**
* @author peng-yongsheng
*/
public enum MemoryPoolType {
CODE_CACHE_USAGE, NEWGEN_USAGE, OLDGEN_USAGE, SURVIVOR_USAGE, PERMGEN_USAGE, METASPACE_USAGE
}
/*
* 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.skywalking.oap.server.core.source;
/**
* @author peng-yongsheng
*/
public enum RequestType {
DATABASE, HTTP, RPC, gRPC
}
......@@ -22,5 +22,6 @@ package org.apache.skywalking.oap.server.core.source;
* @author peng-yongsheng
*/
public enum Scope {
All, Service, ServiceInstance, Endpoint, ServiceRelation, ServiceInstanceRelation, EndpointRelation, NetworkAddress
All, Service, ServiceInstance, Endpoint, ServiceRelation, ServiceInstanceRelation, EndpointRelation, NetworkAddress,
ServiceInstanceJVMCPU, ServiceInstanceJVMMemory, ServiceInstanceJVMMemoryPool, ServiceInstanceJVMGC
}
......@@ -18,14 +18,24 @@
package org.apache.skywalking.oap.server.core.source;
import lombok.*;
import org.apache.skywalking.oap.server.core.source.annotation.SourceType;
/**
* @author wusheng
* @author wusheng, peng-yongsheng
*/
@SourceType
public class Service extends Source {
@Override public Scope scope() {
return Scope.Service;
}
@Getter @Setter private int id;
@Getter @Setter private String name;
@Getter @Setter private String serviceInstanceName;
@Getter @Setter private String endpointName;
@Getter @Setter private int latency;
@Getter @Setter private boolean status;
@Getter @Setter private int responseCode;
@Getter @Setter private RequestType type;
}
/*
* 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.skywalking.oap.server.core.source;
import lombok.*;
import org.apache.skywalking.oap.server.core.source.annotation.SourceType;
/**
* @author peng-yongsheng
*/
@SourceType
public class ServiceInstanceJVMCPU extends Source {
@Override public Scope scope() {
return Scope.ServiceInstanceJVMCPU;
}
@Getter @Setter private int id;
@Getter @Setter private String name;
@Getter @Setter private String serviceName;
@Getter @Setter private int serviceInstanceId;
@Getter @Setter private double usePercent;
}
/*
* 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.skywalking.oap.server.core.source;
import lombok.*;
import org.apache.skywalking.oap.server.core.source.annotation.SourceType;
/**
* @author peng-yongsheng
*/
@SourceType
public class ServiceInstanceJVMGC extends Source {
@Override public Scope scope() {
return Scope.ServiceInstanceJVMGC;
}
@Getter @Setter private int id;
@Getter @Setter private String name;
@Getter @Setter private String serviceName;
@Getter @Setter private int serviceInstanceId;
@Getter @Setter private GCPhrase phrase;
@Getter @Setter private long time;
@Getter @Setter private long count;
}
/*
* 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.skywalking.oap.server.core.source;
import lombok.*;
/**
* @author peng-yongsheng
*/
public class ServiceInstanceJVMMemory extends Source {
@Override public Scope scope() {
return Scope.ServiceInstanceJVMMemory;
}
@Getter @Setter private int id;
@Getter @Setter private String name;
@Getter @Setter private String serviceName;
@Getter @Setter private int serviceInstanceId;
@Getter @Setter private boolean isHeap;
@Getter @Setter private long init;
@Getter @Setter private long max;
@Getter @Setter private long used;
@Getter @Setter private long committed;
}
/*
* 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.skywalking.oap.server.core.source;
import lombok.*;
/**
* @author peng-yongsheng
*/
public class ServiceInstanceJVMMemoryPool extends Source {
@Override public Scope scope() {
return Scope.ServiceInstanceJVMMemoryPool;
}
@Getter @Setter private int id;
@Getter @Setter private String name;
@Getter @Setter private String serviceName;
@Getter @Setter private int serviceInstanceId;
@Getter @Setter private MemoryPoolType poolType;
@Getter @Setter private long init;
@Getter @Setter private long max;
@Getter @Setter private long used;
@Getter @Setter private long committed;
}
......@@ -19,13 +19,13 @@
package org.apache.skywalking.oap.server.core.analysis.indicator.define;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.AvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
/**
* @author peng-yongsheng
*/
public class TestAvgIndicator extends AvgIndicator {
public class TestLongAvgIndicator extends LongAvgIndicator {
@Setter @Getter private int id;
......
/*
* 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.skywalking.oap.server.library.util;
import java.text.*;
import java.util.*;
/**
* @author peng-yongsheng
*/
public enum TimeBucketUtils {
INSTANCE;
public long getMinuteTimeBucket(long time) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
long year = calendar.get(Calendar.YEAR);
long month = calendar.get(Calendar.MONTH) + 1;
long day = calendar.get(Calendar.DAY_OF_MONTH);
long hour = calendar.get(Calendar.HOUR_OF_DAY);
long minute = calendar.get(Calendar.MINUTE);
return year * 100000000 + month * 1000000 + day * 10000 + hour * 100 + minute;
}
public long getSecondTimeBucket(long time) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
long year = calendar.get(Calendar.YEAR);
long month = calendar.get(Calendar.MONTH) + 1;
long day = calendar.get(Calendar.DAY_OF_MONTH);
long hour = calendar.get(Calendar.HOUR_OF_DAY);
long minute = calendar.get(Calendar.MINUTE);
long second = calendar.get(Calendar.SECOND);
return year * 10000000000L + month * 100000000 + day * 1000000 + hour * 10000 + minute * 100 + second;
}
public String formatMinuteTimeBucket(long minuteTimeBucket) throws ParseException {
SimpleDateFormat minuteDateFormat = new SimpleDateFormat("yyyyMMddHHmm");
Date date = minuteDateFormat.parse(String.valueOf(minuteTimeBucket));
SimpleDateFormat parsedMinuteDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return parsedMinuteDateFormat.format(date);
}
public long minuteToHour(long minuteBucket) {
return minuteBucket / 100;
}
public long minuteToDay(long minuteBucket) {
return minuteBucket / 100 / 100;
}
public long minuteToMonth(long minuteBucket) {
return minuteBucket / 100 / 100 / 100;
}
}
......@@ -35,6 +35,7 @@
<module>skywalking-mesh-receiver-plugin</module>
<module>skywalking-istio-telemetry-receiver-plugin</module>
<module>skywalking-register-receiver-plugin</module>
<module>skywalking-jvm-receiver-plugin</module>
</modules>
<dependencies>
......@@ -43,6 +44,11 @@
<artifactId>server-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-network</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>library-module</artifactId>
......
......@@ -30,14 +30,6 @@
<artifactId>skywalking-istio-telemetry-receiver-plugin</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>server-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>server-receiver-plugin</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>6.0.0-alpha-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>skywalking-jvm-receiver-plugin</artifactId>
<packaging>jar</packaging>
</project>
\ No newline at end of file
......@@ -16,18 +16,20 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.generated.service;
package org.apache.skywalking.oap.server.receiver.jvm.module;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.source.Service;
import org.apache.skywalking.oap.server.library.module.ModuleDefine;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
* @author peng-yongsheng
*/
public class ServiceDispatcher implements SourceDispatcher<Service> {
@Override public void dispatch(Service source) {
public class JVMModule extends ModuleDefine {
@Override public String name() {
return "receiver-jvm";
}
@Override public Class[] services() {
return new Class[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.skywalking.oap.server.receiver.jvm.provider;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
import org.apache.skywalking.oap.server.library.module.*;
import org.apache.skywalking.oap.server.receiver.jvm.module.JVMModule;
import org.apache.skywalking.oap.server.receiver.jvm.provider.handler.JVMMetricsServiceHandler;
/**
* @author peng-yongsheng
*/
public class JVMModuleProvider extends ModuleProvider {
@Override public String name() {
return "default";
}
@Override public Class<? extends ModuleDefine> module() {
return JVMModule.class;
}
@Override public ModuleConfig createConfigBeanIfAbsent() {
return null;
}
@Override public void prepare() {
}
@Override public void start() {
GRPCHandlerRegister grpcHandlerRegister = getManager().find(CoreModule.NAME).getService(GRPCHandlerRegister.class);
grpcHandlerRegister.addHandler(new JVMMetricsServiceHandler(getManager()));
}
@Override public void notifyAfterCompleted() {
}
@Override public String[] requiredModules() {
return new String[] {CoreModule.NAME};
}
}
/*
* 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.skywalking.oap.server.receiver.jvm.provider.handler;
import io.grpc.stub.StreamObserver;
import java.util.List;
import org.apache.skywalking.apm.network.language.agent.*;
import org.apache.skywalking.oap.server.core.*;
import org.apache.skywalking.oap.server.core.source.GCPhrase;
import org.apache.skywalking.oap.server.core.source.*;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler;
import org.apache.skywalking.oap.server.library.util.TimeBucketUtils;
import org.slf4j.*;
/**
* @author peng-yongsheng
*/
public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsServiceImplBase implements GRPCHandler {
private static final Logger logger = LoggerFactory.getLogger(JVMMetricsServiceHandler.class);
private final SourceReceiver sourceReceiver;
public JVMMetricsServiceHandler(ModuleManager moduleManager) {
this.sourceReceiver = moduleManager.find(CoreModule.NAME).getService(SourceReceiver.class);
}
@Override public void collect(JVMMetrics request, StreamObserver<Downstream> responseObserver) {
int serviceInstanceId = request.getApplicationInstanceId();
if (logger.isDebugEnabled()) {
logger.debug("receive the jvm metric from application instance, id: {}", serviceInstanceId);
}
request.getMetricsList().forEach(metric -> {
long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metric.getTime());
sendToCpuMetricProcess(serviceInstanceId, minuteTimeBucket, metric.getCpu());
sendToMemoryMetricProcess(serviceInstanceId, minuteTimeBucket, metric.getMemoryList());
sendToMemoryPoolMetricProcess(serviceInstanceId, minuteTimeBucket, metric.getMemoryPoolList());
sendToGCMetricProcess(serviceInstanceId, minuteTimeBucket, metric.getGcList());
sendToInstanceHeartBeatProcess(serviceInstanceId, metric.getTime());
});
responseObserver.onNext(Downstream.newBuilder().build());
responseObserver.onCompleted();
}
private void sendToCpuMetricProcess(int serviceInstanceId, long timeBucket, CPU cpu) {
ServiceInstanceJVMCPU serviceInstanceJVMCPU = new ServiceInstanceJVMCPU();
serviceInstanceJVMCPU.setId(serviceInstanceId);
serviceInstanceJVMCPU.setName(Const.EMPTY_STRING);
serviceInstanceJVMCPU.setServiceInstanceId(serviceInstanceId);
serviceInstanceJVMCPU.setServiceName(Const.EMPTY_STRING);
serviceInstanceJVMCPU.setUsePercent(cpu.getUsagePercent());
serviceInstanceJVMCPU.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceInstanceJVMCPU);
}
private void sendToGCMetricProcess(int serviceInstanceId, long timeBucket, List<GC> gcs) {
gcs.forEach(gc -> {
ServiceInstanceJVMGC serviceInstanceJVMGC = new ServiceInstanceJVMGC();
serviceInstanceJVMGC.setId(serviceInstanceId);
serviceInstanceJVMGC.setName(Const.EMPTY_STRING);
serviceInstanceJVMGC.setServiceInstanceId(serviceInstanceId);
serviceInstanceJVMGC.setServiceName(Const.EMPTY_STRING);
switch (gc.getPhrase()) {
case NEW:
serviceInstanceJVMGC.setPhrase(GCPhrase.NEW);
case OLD:
serviceInstanceJVMGC.setPhrase(GCPhrase.OLD);
}
serviceInstanceJVMGC.setTime(gc.getTime());
serviceInstanceJVMGC.setCount(gc.getCount());
serviceInstanceJVMGC.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceInstanceJVMGC);
});
}
private void sendToMemoryMetricProcess(int serviceInstanceId, long timeBucket, List<Memory> memories) {
memories.forEach(memory -> {
ServiceInstanceJVMMemory serviceInstanceJVMMemory = new ServiceInstanceJVMMemory();
serviceInstanceJVMMemory.setId(serviceInstanceId);
serviceInstanceJVMMemory.setName(Const.EMPTY_STRING);
serviceInstanceJVMMemory.setServiceInstanceId(serviceInstanceId);
serviceInstanceJVMMemory.setServiceName(Const.EMPTY_STRING);
serviceInstanceJVMMemory.setHeap(memory.getIsHeap());
serviceInstanceJVMMemory.setInit(memory.getInit());
serviceInstanceJVMMemory.setMax(memory.getMax());
serviceInstanceJVMMemory.setUsed(memory.getUsed());
serviceInstanceJVMMemory.setCommitted(memory.getCommitted());
serviceInstanceJVMMemory.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceInstanceJVMMemory);
});
}
private void sendToMemoryPoolMetricProcess(int serviceInstanceId, long timeBucket,
List<MemoryPool> memoryPools) {
memoryPools.forEach(memoryPool -> {
ServiceInstanceJVMMemoryPool serviceInstanceJVMMemoryPool = new ServiceInstanceJVMMemoryPool();
serviceInstanceJVMMemoryPool.setId(serviceInstanceId);
serviceInstanceJVMMemoryPool.setName(Const.EMPTY_STRING);
serviceInstanceJVMMemoryPool.setServiceInstanceId(serviceInstanceId);
serviceInstanceJVMMemoryPool.setServiceName(Const.EMPTY_STRING);
switch (memoryPool.getType()) {
case NEWGEN_USAGE:
serviceInstanceJVMMemoryPool.setPoolType(MemoryPoolType.NEWGEN_USAGE);
case OLDGEN_USAGE:
serviceInstanceJVMMemoryPool.setPoolType(MemoryPoolType.OLDGEN_USAGE);
case PERMGEN_USAGE:
serviceInstanceJVMMemoryPool.setPoolType(MemoryPoolType.PERMGEN_USAGE);
case SURVIVOR_USAGE:
serviceInstanceJVMMemoryPool.setPoolType(MemoryPoolType.SURVIVOR_USAGE);
case METASPACE_USAGE:
serviceInstanceJVMMemoryPool.setPoolType(MemoryPoolType.METASPACE_USAGE);
case CODE_CACHE_USAGE:
serviceInstanceJVMMemoryPool.setPoolType(MemoryPoolType.CODE_CACHE_USAGE);
}
serviceInstanceJVMMemoryPool.setInit(memoryPool.getInit());
serviceInstanceJVMMemoryPool.setMax(memoryPool.getMax());
serviceInstanceJVMMemoryPool.setUsed(memoryPool.getUsed());
serviceInstanceJVMMemoryPool.setCommitted(memoryPool.getCommited());
serviceInstanceJVMMemoryPool.setTimeBucket(timeBucket);
sourceReceiver.receive(serviceInstanceJVMMemoryPool);
});
}
private void sendToInstanceHeartBeatProcess(int instanceId, long heartBeatTime) {
// instanceHeartBeatService.heartBeat(instanceId, heartBeatTime);
}
}
#
# 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.
#
#
org.apache.skywalking.oap.server.receiver.jvm.module.JVMModule
\ No newline at end of file
#
# 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.
#
#
org.apache.skywalking.oap.server.receiver.jvm.provider.JVMModuleProvider
\ No newline at end of file
/*
* 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.skywalking.oap.server.receiver.jvm.provider.handler;
import io.grpc.*;
import org.apache.skywalking.apm.network.language.agent.*;
/**
* @author peng-yongsheng
*/
public class JVMMetricsServiceHandlerMainTest {
public static void main(String[] args) {
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
JVMMetricsServiceGrpc.JVMMetricsServiceBlockingStub stub = JVMMetricsServiceGrpc.newBlockingStub(channel);
JVMMetrics.Builder jvmMetrics = JVMMetrics.newBuilder();
jvmMetrics.setApplicationInstanceId(1);
JVMMetric.Builder jvmMetricBuilder = JVMMetric.newBuilder();
jvmMetricBuilder.setTime(System.currentTimeMillis());
buildCPUMetric(jvmMetricBuilder);
buildGCMetric(jvmMetricBuilder);
buildMemoryMetric(jvmMetricBuilder);
buildMemoryPoolMetric(jvmMetricBuilder);
jvmMetrics.addMetrics(jvmMetricBuilder);
stub.collect(jvmMetrics.build());
}
private static void buildMemoryPoolMetric(JVMMetric.Builder metricBuilder) {
MemoryPool.Builder codeCache = MemoryPool.newBuilder();
codeCache.setInit(10);
codeCache.setMax(100);
codeCache.setCommited(10);
codeCache.setUsed(50);
codeCache.setType(PoolType.CODE_CACHE_USAGE);
metricBuilder.addMemoryPool(codeCache);
MemoryPool.Builder newGen = MemoryPool.newBuilder();
newGen.setInit(10);
newGen.setMax(100);
newGen.setCommited(10);
newGen.setUsed(50);
newGen.setType(PoolType.NEWGEN_USAGE);
metricBuilder.addMemoryPool(newGen);
MemoryPool.Builder oldGen = MemoryPool.newBuilder();
oldGen.setInit(10);
oldGen.setMax(100);
oldGen.setCommited(10);
oldGen.setUsed(50);
oldGen.setType(PoolType.OLDGEN_USAGE);
metricBuilder.addMemoryPool(oldGen);
MemoryPool.Builder survivor = MemoryPool.newBuilder();
survivor.setInit(10);
survivor.setMax(100);
survivor.setCommited(10);
survivor.setUsed(50);
survivor.setType(PoolType.SURVIVOR_USAGE);
metricBuilder.addMemoryPool(survivor);
MemoryPool.Builder permGen = MemoryPool.newBuilder();
permGen.setInit(10);
permGen.setMax(100);
permGen.setCommited(10);
permGen.setUsed(50);
permGen.setType(PoolType.PERMGEN_USAGE);
metricBuilder.addMemoryPool(permGen);
MemoryPool.Builder metaSpace = MemoryPool.newBuilder();
metaSpace.setInit(10);
metaSpace.setMax(100);
metaSpace.setCommited(10);
metaSpace.setUsed(50);
metaSpace.setType(PoolType.METASPACE_USAGE);
metricBuilder.addMemoryPool(metaSpace);
}
private static void buildMemoryMetric(JVMMetric.Builder metricBuilder) {
Memory.Builder isHeap = Memory.newBuilder();
isHeap.setInit(20);
isHeap.setMax(100);
isHeap.setCommitted(20);
isHeap.setUsed(60);
isHeap.setIsHeap(true);
metricBuilder.addMemory(isHeap);
Memory.Builder nonHeap = Memory.newBuilder();
nonHeap.setInit(20);
nonHeap.setMax(100);
nonHeap.setCommitted(20);
nonHeap.setUsed(60);
nonHeap.setIsHeap(false);
metricBuilder.addMemory(nonHeap);
}
private static void buildGCMetric(JVMMetric.Builder metricBuilder) {
GC.Builder newGC = GC.newBuilder();
newGC.setPhrase(GCPhrase.NEW);
newGC.setCount(2);
newGC.setTime(1000);
metricBuilder.addGc(newGC);
GC.Builder oldGC = GC.newBuilder();
oldGC.setPhrase(GCPhrase.OLD);
oldGC.setCount(4);
oldGC.setTime(49);
metricBuilder.addGc(oldGC);
}
private static void buildCPUMetric(JVMMetric.Builder metricBuilder) {
CPU.Builder cpu = CPU.newBuilder();
cpu.setUsagePercent(20);
metricBuilder.setCpu(cpu.build());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout charset="UTF-8" pattern="%d - %c -%-4r [%t] %-5p %x - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
......@@ -74,6 +74,11 @@
<artifactId>skywalking-register-receiver-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>skywalking-jvm-receiver-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<!-- receiver module -->
<!-- storage module -->
......
......@@ -51,6 +51,8 @@ storage:
monthMetricDataTTL: 18 # Unit is month
receiver-register:
default:
receiver-jvm:
default:
service-mesh:
default:
istio-telemetry:
......
......@@ -38,6 +38,6 @@ public class ElasticSearchColumnTypeMappingTestCase {
Assert.assertEquals("double", mapping.transform(double.class));
Assert.assertEquals("double", mapping.transform(Double.class));
Assert.assertEquals("text", mapping.transform(String.class));
Assert.assertEquals("keyword", mapping.transform(String.class));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册