提交 8a892219 编写于 作者: wu-sheng's avatar wu-sheng

Push generated codes with percent and percent boolean expression. CC @peng-yongsheng

上级 0ebbb0a5
/*
* 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.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
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;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "endpoint_avg", builder = EndpointAvgIndicator.Builder.class)
public class EndpointAvgIndicator extends AvgIndicator {
@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);
}
@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;
EndpointAvgIndicator indicator = (EndpointAvgIndicator)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.setDataLongs(1, getSummation());
remoteBuilder.setDataLongs(2, getValue());
remoteBuilder.setDataLongs(3, getTimeBucket());
remoteBuilder.setDataIntegers(0, getId());
remoteBuilder.setDataIntegers(1, getServiceId());
remoteBuilder.setDataIntegers(2, getServiceInstanceId());
remoteBuilder.setDataIntegers(3, getCount());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setSummation(remoteData.getDataLongs(1));
setValue(remoteData.getDataLongs(2));
setTimeBucket(remoteData.getDataLongs(3));
setId(remoteData.getDataIntegers(0));
setServiceId(remoteData.getDataIntegers(1));
setServiceInstanceId(remoteData.getDataIntegers(2));
setCount(remoteData.getDataIntegers(3));
}
public static class Builder implements StorageBuilder<EndpointAvgIndicator> {
@Override public Map<String, Object> data2Map(EndpointAvgIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("id", storageData.getId());
map.put("service_id", storageData.getServiceId());
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 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"));
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.endpoint;
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.Endpoint;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class EndpointDispatcher implements SourceDispatcher<Endpoint> {
@Override public void dispatch(Endpoint source) {
doEndpointAvg(source);
doEndpointPercent(source);
}
private void doEndpointAvg(Endpoint source) {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setId(source.getId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointPercent(Endpoint source) {
EndpointPercentIndicator indicator = new EndpointPercentIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setId(source.getId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(new org.apache.skywalking.oap.server.core.analysis.indicator.expression.BooleanBinaryMatch(), source.isStatus(), true);
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.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
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;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "endpoint_percent", builder = EndpointPercentIndicator.Builder.class)
public class EndpointPercentIndicator extends PercentIndicator {
@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);
}
@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;
EndpointPercentIndicator indicator = (EndpointPercentIndicator)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.setDataLongs(1, getTotal());
remoteBuilder.setDataLongs(2, getMatch());
remoteBuilder.setDataLongs(3, getTimeBucket());
remoteBuilder.setDataIntegers(0, getId());
remoteBuilder.setDataIntegers(1, getServiceId());
remoteBuilder.setDataIntegers(2, getServiceInstanceId());
remoteBuilder.setDataIntegers(3, getPercentage());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setTotal(remoteData.getDataLongs(1));
setMatch(remoteData.getDataLongs(2));
setTimeBucket(remoteData.getDataLongs(3));
setId(remoteData.getDataIntegers(0));
setServiceId(remoteData.getDataIntegers(1));
setServiceInstanceId(remoteData.getDataIntegers(2));
setPercentage(remoteData.getDataIntegers(3));
}
public static class Builder implements StorageBuilder<EndpointPercentIndicator> {
@Override public Map<String, Object> data2Map(EndpointPercentIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("id", storageData.getId());
map.put("service_id", storageData.getServiceId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("total", storageData.getTotal());
map.put("percentage", storageData.getPercentage());
map.put("match", storageData.getMatch());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@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"));
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.service;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.source.Service;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceDispatcher implements SourceDispatcher<Service> {
@Override public void dispatch(Service source) {
}
}
/*
* 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.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 org.apache.skywalking.oap.server.core.analysis.indicator.expression.BooleanBinaryMatch;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author wusheng
*/
@IndicatorOperator
public abstract class PercentIndicator extends Indicator {
protected static final String TOTAL = "total";
protected static final String MATCH = "match";
protected static final String PERCENTAGE = "percentage";
@Getter @Setter @Column(columnName = TOTAL) private long total;
@Getter @Setter @Column(columnName = PERCENTAGE) private int percentage;
@Getter @Setter @Column(columnName = MATCH) private long match;
@Entrance
public final void combine(@Expression BooleanBinaryMatch expression, @ExpressionArg0 Object leftValue,
@ExpressionArg1 Object rightValue) {
expression.setLeft(leftValue);
expression.setRight(rightValue);
if (expression.match()) {
match++;
}
total++;
}
@Override public final void combine(Indicator indicator) {
total += ((PercentIndicator)indicator).total;
match += ((PercentIndicator)indicator).match;
}
}
/*
* 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.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author wusheng
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface Expression {
}
/*
* 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.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author wusheng
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExpressionArg0 {
}
/*
* 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.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author wusheng
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExpressionArg1 {
}
/*
* 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.expression;
/**
* BinaryMatchExpression accepts two calculate factors,
* and return the True/False result.
*
* @author wusheng
*/
public abstract class BinaryMatchExpression {
protected Object left;
protected Object right;
public void setLeft(Object left) {
this.left = left;
}
public void setRight(Object right) {
this.right = right;
}
public abstract boolean match();
}
/*
* 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.expression;
/**
*
* @author wusheng
*/
public class BooleanBinaryMatch extends BinaryMatchExpression {
@Override public boolean match() {
return left == right;
}
}
/*
* 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 org.apache.skywalking.oap.server.core.source.annotation.SourceType;
/**
* @author wusheng
*/
@SourceType
public class Service extends Source {
@Override public Scope scope() {
return Scope.Service;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册