EndpointP99Indicator.java 8.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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.*;
23
import org.apache.skywalking.oap.server.core.Const;
24 25
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
26
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
27 28 29
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;
30
import org.apache.skywalking.oap.server.core.storage.annotation.*;
31 32
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
33 34 35 36 37 38 39 40

/**
 * This class is auto generated. Please don't change this class manually.
 *
 * @author Observability Analysis Language code generator
 */
@IndicatorType
@StreamData
41
@StorageEntity(name = "endpoint_p99", builder = EndpointP99Indicator.Builder.class, source = Scope.Endpoint)
42
public class EndpointP99Indicator extends P99Indicator implements AlarmSupported {
43

44
    @Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId;
wu-sheng's avatar
wu-sheng 已提交
45 46
    @Setter @Getter @Column(columnName = "service_id")  private int serviceId;
    @Setter @Getter @Column(columnName = "service_instance_id")  private int serviceInstanceId;
47 48

    @Override public String id() {
49
        String splitJointId = String.valueOf(getTimeBucket());
wu-sheng's avatar
wu-sheng 已提交
50
        splitJointId += Const.ID_SPLIT + entityId;
51
        return splitJointId;
52 53 54 55
    }

    @Override public int hashCode() {
        int result = 17;
wu-sheng's avatar
wu-sheng 已提交
56
        result = 31 * result + entityId.hashCode();
57 58 59 60
        result = 31 * result + (int)getTimeBucket();
        return result;
    }

wu-sheng's avatar
wu-sheng 已提交
61 62 63 64 65 66
    @Override public int remoteHashCode() {
        int result = 17;
        result = 31 * result + entityId.hashCode();
        return result;
    }

67 68 69 70 71 72 73 74
    @Override public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;

75
        EndpointP99Indicator indicator = (EndpointP99Indicator)obj;
wu-sheng's avatar
wu-sheng 已提交
76
        if (!entityId.equals(indicator.entityId))
77
            return false;
78

79 80 81 82 83 84 85 86
        if (getTimeBucket() != indicator.getTimeBucket())
            return false;

        return true;
    }

    @Override public RemoteData.Builder serialize() {
        RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
87
        remoteBuilder.addDataStrings(getEntityId());
88

89
        remoteBuilder.addDataLongs(getTimeBucket());
90 91


92 93 94 95
        remoteBuilder.addDataIntegers(getServiceId());
        remoteBuilder.addDataIntegers(getServiceInstanceId());
        remoteBuilder.addDataIntegers(getValue());
        remoteBuilder.addDataIntegers(getPrecision());
96
        getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
97 98 99 100 101

        return remoteBuilder;
    }

    @Override public void deserialize(RemoteData remoteData) {
wu-sheng's avatar
wu-sheng 已提交
102
        setEntityId(remoteData.getDataStrings(0));
103

104
        setTimeBucket(remoteData.getDataLongs(0));
105 106


wu-sheng's avatar
wu-sheng 已提交
107 108
        setServiceId(remoteData.getDataIntegers(0));
        setServiceInstanceId(remoteData.getDataIntegers(1));
109 110
        setValue(remoteData.getDataIntegers(2));
        setPrecision(remoteData.getDataIntegers(3));
111

112 113 114 115
        setDetailGroup(new IntKeyLongValueArray(30));
        remoteData.getDataIntLongPairListList().forEach(element -> {
            getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
        });
116

117 118
    }

119
    @Override public AlarmMeta getAlarmMeta() {
120
        return new AlarmMeta("endpoint_p99", Scope.Endpoint, entityId);
121 122
    }

123 124
    @Override
    public Indicator toHour() {
125
        EndpointP99Indicator indicator = new EndpointP99Indicator();
wu-sheng's avatar
wu-sheng 已提交
126
        indicator.setEntityId(this.getEntityId());
127 128
        indicator.setServiceId(this.getServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
129 130
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
131 132 133 134
        org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
        newValue.copyFrom(this.getDetailGroup());
        indicator.setDetailGroup(newValue);
        indicator.setTimeBucket(toTimeBucketInHour());
135 136 137 138 139
        return indicator;
    }

    @Override
    public Indicator toDay() {
140
        EndpointP99Indicator indicator = new EndpointP99Indicator();
wu-sheng's avatar
wu-sheng 已提交
141
        indicator.setEntityId(this.getEntityId());
142 143
        indicator.setServiceId(this.getServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
144 145
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
146 147 148 149
        org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
        newValue.copyFrom(this.getDetailGroup());
        indicator.setDetailGroup(newValue);
        indicator.setTimeBucket(toTimeBucketInDay());
150 151 152 153 154
        return indicator;
    }

    @Override
    public Indicator toMonth() {
155
        EndpointP99Indicator indicator = new EndpointP99Indicator();
wu-sheng's avatar
wu-sheng 已提交
156
        indicator.setEntityId(this.getEntityId());
157 158
        indicator.setServiceId(this.getServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
159 160
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
161 162 163 164
        org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
        newValue.copyFrom(this.getDetailGroup());
        indicator.setDetailGroup(newValue);
        indicator.setTimeBucket(toTimeBucketInMonth());
165 166 167
        return indicator;
    }

168
    public static class Builder implements StorageBuilder<EndpointP99Indicator> {
169

170
        @Override public Map<String, Object> data2Map(EndpointP99Indicator storageData) {
171
            Map<String, Object> map = new HashMap<>();
wu-sheng's avatar
wu-sheng 已提交
172
            map.put("entity_id", storageData.getEntityId());
173 174
            map.put("service_id", storageData.getServiceId());
            map.put("service_instance_id", storageData.getServiceInstanceId());
175 176 177
            map.put("value", storageData.getValue());
            map.put("precision", storageData.getPrecision());
            map.put("detail_group", storageData.getDetailGroup());
178 179 180 181
            map.put("time_bucket", storageData.getTimeBucket());
            return map;
        }

182 183
        @Override public EndpointP99Indicator map2Data(Map<String, Object> dbMap) {
            EndpointP99Indicator indicator = new EndpointP99Indicator();
wu-sheng's avatar
wu-sheng 已提交
184
            indicator.setEntityId((String)dbMap.get("entity_id"));
185 186
            indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
            indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
187 188
            indicator.setValue(((Number)dbMap.get("value")).intValue());
            indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
彭勇升 pengys 已提交
189
            indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
190
            indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
191 192 193 194
            return indicator;
        }
    }
}