EndpointRelationCpmIndicator.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 23
/*
 * 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.endpointrelation;

import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
24
import org.apache.skywalking.oap.server.core.alarm.*;
25 26 27 28 29
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.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_relation_cpm", builder = EndpointRelationCpmIndicator.Builder.class)
public class EndpointRelationCpmIndicator extends CPMIndicator implements AlarmSupported {
42

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

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

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

wu-sheng's avatar
wu-sheng 已提交
62 63 64 65 66 67 68

    @Override public int remoteHashCode() {
        int result = 17;
        result = 31 * result + entityId.hashCode();
        return result;
    }

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

77
        EndpointRelationCpmIndicator indicator = (EndpointRelationCpmIndicator)obj;
wu-sheng's avatar
wu-sheng 已提交
78
        if (entityId != indicator.entityId)
79 80 81 82 83 84 85 86 87 88
            return false;

        if (getTimeBucket() != indicator.getTimeBucket())
            return false;

        return true;
    }

    @Override public RemoteData.Builder serialize() {
        RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
wu-sheng's avatar
wu-sheng 已提交
89
        remoteBuilder.setDataStrings(0, getEntityId());
90

91 92
        remoteBuilder.setDataLongs(0, getValue());
        remoteBuilder.setDataLongs(1, getTotal());
93 94 95
        remoteBuilder.setDataLongs(2, getTimeBucket());


wu-sheng's avatar
wu-sheng 已提交
96 97 98 99
        remoteBuilder.setDataIntegers(0, getServiceId());
        remoteBuilder.setDataIntegers(1, getChildServiceId());
        remoteBuilder.setDataIntegers(2, getServiceInstanceId());
        remoteBuilder.setDataIntegers(3, getChildServiceInstanceId());
100 101 102 103 104

        return remoteBuilder;
    }

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

107 108
        setValue(remoteData.getDataLongs(0));
        setTotal(remoteData.getDataLongs(1));
109 110 111
        setTimeBucket(remoteData.getDataLongs(2));


wu-sheng's avatar
wu-sheng 已提交
112 113 114 115
        setServiceId(remoteData.getDataIntegers(0));
        setChildServiceId(remoteData.getDataIntegers(1));
        setServiceInstanceId(remoteData.getDataIntegers(2));
        setChildServiceInstanceId(remoteData.getDataIntegers(3));
116 117


118 119 120
    }

    @Override public AlarmMeta getAlarmMeta() {
121
        return new AlarmMeta("endpoint_relation_cpm", Scope.EndpointRelation, entityId);
122 123
    }

124 125
    @Override
    public Indicator toHour() {
126
        EndpointRelationCpmIndicator indicator = new EndpointRelationCpmIndicator();
127
        indicator.setTimeBucket(toTimeBucketInHour());
wu-sheng's avatar
wu-sheng 已提交
128
        indicator.setEntityId(this.getEntityId());
129 130 131 132 133
        indicator.setServiceId(this.getServiceId());
        indicator.setChildServiceId(this.getChildServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
        indicator.setChildServiceInstanceId(this.getChildServiceInstanceId());
        indicator.setValue(this.getValue());
134
        indicator.setTotal(this.getTotal());
135 136 137 138 139
        return indicator;
    }

    @Override
    public Indicator toDay() {
140
        EndpointRelationCpmIndicator indicator = new EndpointRelationCpmIndicator();
141
        indicator.setTimeBucket(toTimeBucketInDay());
wu-sheng's avatar
wu-sheng 已提交
142
        indicator.setEntityId(this.getEntityId());
143 144 145 146 147
        indicator.setServiceId(this.getServiceId());
        indicator.setChildServiceId(this.getChildServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
        indicator.setChildServiceInstanceId(this.getChildServiceInstanceId());
        indicator.setValue(this.getValue());
148
        indicator.setTotal(this.getTotal());
149 150 151 152 153
        return indicator;
    }

    @Override
    public Indicator toMonth() {
154
        EndpointRelationCpmIndicator indicator = new EndpointRelationCpmIndicator();
155
        indicator.setTimeBucket(toTimeBucketInMonth());
wu-sheng's avatar
wu-sheng 已提交
156
        indicator.setEntityId(this.getEntityId());
157 158 159 160 161
        indicator.setServiceId(this.getServiceId());
        indicator.setChildServiceId(this.getChildServiceId());
        indicator.setServiceInstanceId(this.getServiceInstanceId());
        indicator.setChildServiceInstanceId(this.getChildServiceInstanceId());
        indicator.setValue(this.getValue());
162
        indicator.setTotal(this.getTotal());
163 164 165
        return indicator;
    }

166
    public static class Builder implements StorageBuilder<EndpointRelationCpmIndicator> {
167

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

181 182
        @Override public EndpointRelationCpmIndicator map2Data(Map<String, Object> dbMap) {
            EndpointRelationCpmIndicator indicator = new EndpointRelationCpmIndicator();
wu-sheng's avatar
wu-sheng 已提交
183
            indicator.setEntityId((String)dbMap.get("entity_id"));
184 185 186 187 188
            indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
            indicator.setChildServiceId(((Number)dbMap.get("child_service_id")).intValue());
            indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
            indicator.setChildServiceInstanceId(((Number)dbMap.get("child_service_instance_id")).intValue());
            indicator.setValue(((Number)dbMap.get("value")).longValue());
189
            indicator.setTotal(((Number)dbMap.get("total")).longValue());
190 191 192 193 194
            indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
            return indicator;
        }
    }
}