AllP50Indicator.java 6.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
/*
 * 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.all;

import java.util.*;
22
import org.apache.skywalking.oap.server.core.alarm.*;
23 24 25 26
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;
wu-sheng's avatar
wu-sheng 已提交
27
import org.apache.skywalking.oap.server.core.source.Scope;
28 29
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntity;
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

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


    @Override public String id() {
        String splitJointId = String.valueOf(getTimeBucket());
        return splitJointId;
    }

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

wu-sheng's avatar
wu-sheng 已提交
53 54 55 56 57
    @Override public int remoteHashCode() {
        int result = 17;
        return result;
    }

58 59 60 61 62 63 64 65 66 67 68 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;

        AllP50Indicator indicator = (AllP50Indicator)obj;

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

        return true;
    }

    @Override public RemoteData.Builder serialize() {
        RemoteData.Builder remoteBuilder = RemoteData.newBuilder();

77
        remoteBuilder.addDataLongs(getTimeBucket());
78 79


80 81
        remoteBuilder.addDataIntegers(getValue());
        remoteBuilder.addDataIntegers(getPrecision());
82 83 84 85 86 87 88 89 90 91 92 93 94
        getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));

        return remoteBuilder;
    }

    @Override public void deserialize(RemoteData remoteData) {

        setTimeBucket(remoteData.getDataLongs(0));


        setValue(remoteData.getDataIntegers(0));
        setPrecision(remoteData.getDataIntegers(1));

95
        setDetailGroup(new IntKeyLongValueArray(30));
96 97 98 99 100 101 102
        remoteData.getDataIntLongPairListList().forEach(element -> {
            getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
        });

    }

    @Override public AlarmMeta getAlarmMeta() {
103
        return new AlarmMeta("all_p50", Scope.All);
104 105
    }

106 107 108 109 110
    @Override
    public Indicator toHour() {
        AllP50Indicator indicator = new AllP50Indicator();
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
111 112 113 114
        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());
115 116 117 118 119 120 121 122
        return indicator;
    }

    @Override
    public Indicator toDay() {
        AllP50Indicator indicator = new AllP50Indicator();
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
123 124 125 126
        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());
127 128 129 130 131 132 133 134
        return indicator;
    }

    @Override
    public Indicator toMonth() {
        AllP50Indicator indicator = new AllP50Indicator();
        indicator.setValue(this.getValue());
        indicator.setPrecision(this.getPrecision());
135 136 137 138
        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());
139 140 141
        return indicator;
    }

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
    public static class Builder implements StorageBuilder<AllP50Indicator> {

        @Override public Map<String, Object> data2Map(AllP50Indicator storageData) {
            Map<String, Object> map = new HashMap<>();
            map.put("value", storageData.getValue());
            map.put("precision", storageData.getPrecision());
            map.put("detail_group", storageData.getDetailGroup());
            map.put("time_bucket", storageData.getTimeBucket());
            return map;
        }

        @Override public AllP50Indicator map2Data(Map<String, Object> dbMap) {
            AllP50Indicator indicator = new AllP50Indicator();
            indicator.setValue(((Number)dbMap.get("value")).intValue());
            indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
彭勇升 pengys 已提交
157
            indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
158 159 160 161 162
            indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
            return indicator;
        }
    }
}