EndpointP90Indicator.java 8.1 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
import org.apache.skywalking.oap.server.core.alarm.*;
25
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
26 27 28
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;
wu-sheng's avatar
wu-sheng 已提交
29
import org.apache.skywalking.oap.server.core.source.Scope;
30 31
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
32 33 34 35 36 37 38 39

/**
 * This class is auto generated. Please don't change this class manually.
 *
 * @author Observability Analysis Language code generator
 */
@IndicatorType
@StreamData
40 41
@StorageEntity(name = "endpoint_p90", builder = EndpointP90Indicator.Builder.class)
public class EndpointP90Indicator extends P90Indicator implements AlarmSupported {
42

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

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

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

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

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

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

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

        return true;
    }

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

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


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

        return remoteBuilder;
    }

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

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


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

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

116 117
    }

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

122 123
    @Override
    public Indicator toHour() {
124
        EndpointP90Indicator indicator = new EndpointP90Indicator();
wu-sheng's avatar
wu-sheng 已提交
125
        indicator.setEntityId(this.getEntityId());
126 127
        indicator.setServiceId(this.getServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
128 129
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
130 131 132 133
        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());
134 135 136 137 138
        return indicator;
    }

    @Override
    public Indicator toDay() {
139
        EndpointP90Indicator indicator = new EndpointP90Indicator();
wu-sheng's avatar
wu-sheng 已提交
140
        indicator.setEntityId(this.getEntityId());
141 142
        indicator.setServiceId(this.getServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
143 144
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
145 146 147 148
        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());
149 150 151 152 153
        return indicator;
    }

    @Override
    public Indicator toMonth() {
154
        EndpointP90Indicator indicator = new EndpointP90Indicator();
wu-sheng's avatar
wu-sheng 已提交
155
        indicator.setEntityId(this.getEntityId());
156 157
        indicator.setServiceId(this.getServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
158 159
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
160 161 162 163
        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());
164 165 166
        return indicator;
    }

167
    public static class Builder implements StorageBuilder<EndpointP90Indicator> {
168

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

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