Instance.java 4.0 KB
Newer Older
P
peng-yongsheng 已提交
1
/*
wu-sheng's avatar
wu-sheng 已提交
2 3 4 5 6 7
 * 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
P
peng-yongsheng 已提交
8 9 10 11 12 13 14 15 16 17 18
 *
 *     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.
 *
 */

19
package org.apache.skywalking.apm.collector.storage.table.register;
P
peng-yongsheng 已提交
20

21
import org.apache.skywalking.apm.collector.core.data.Column;
P
peng-yongsheng 已提交
22
import org.apache.skywalking.apm.collector.core.data.StreamData;
23 24
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
25
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
P
peng-yongsheng 已提交
26 27 28 29

/**
 * @author peng-yongsheng
 */
P
peng-yongsheng 已提交
30
public class Instance extends StreamData {
P
peng-yongsheng 已提交
31 32 33 34 35 36 37 38 39 40 41

    private static final Column[] STRING_COLUMNS = {
        new Column(InstanceTable.COLUMN_ID, new NonOperation()),
        new Column(InstanceTable.COLUMN_AGENT_UUID, new CoverOperation()),
        new Column(InstanceTable.COLUMN_OS_INFO, new CoverOperation()),
    };

    private static final Column[] LONG_COLUMNS = {
        new Column(InstanceTable.COLUMN_REGISTER_TIME, new CoverOperation()),
        new Column(InstanceTable.COLUMN_HEARTBEAT_TIME, new CoverOperation()),
    };
42

P
peng-yongsheng 已提交
43
    private static final Column[] DOUBLE_COLUMNS = {};
44

P
peng-yongsheng 已提交
45 46 47
    private static final Column[] INTEGER_COLUMNS = {
        new Column(InstanceTable.COLUMN_APPLICATION_ID, new CoverOperation()),
        new Column(InstanceTable.COLUMN_INSTANCE_ID, new CoverOperation()),
48 49
        new Column(InstanceTable.COLUMN_ADDRESS_ID, new CoverOperation()),
        new Column(InstanceTable.COLUMN_IS_ADDRESS, new CoverOperation()),
P
peng-yongsheng 已提交
50 51 52 53
    };

    private static final Column[] BYTE_COLUMNS = {};

P
peng-yongsheng 已提交
54
    public Instance() {
55
        super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BYTE_COLUMNS);
P
peng-yongsheng 已提交
56 57
    }

P
peng-yongsheng 已提交
58
    @Override public String getId() {
P
peng-yongsheng 已提交
59 60 61
        return getDataString(0);
    }

P
peng-yongsheng 已提交
62 63 64 65
    @Override public void setId(String id) {
        setDataString(0, id);
    }

P
peng-yongsheng 已提交
66 67 68 69 70 71 72 73
    @Override public String getMetricId() {
        return getId();
    }

    @Override public void setMetricId(String metricId) {
        setId(metricId);
    }

P
peng-yongsheng 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
    public int getApplicationId() {
        return getDataInteger(0);
    }

    public void setApplicationId(Integer applicationId) {
        setDataInteger(0, applicationId);
    }

    public String getAgentUUID() {
        return getDataString(1);
    }

    public void setAgentUUID(String agentUUID) {
        setDataString(1, agentUUID);
    }

    public long getRegisterTime() {
        return getDataLong(0);
    }

    public void setRegisterTime(Long registerTime) {
        setDataLong(0, registerTime);
    }

    public int getInstanceId() {
        return getDataInteger(1);
    }

    public void setInstanceId(Integer instanceId) {
        setDataInteger(1, instanceId);
    }

    public long getHeartBeatTime() {
        return getDataLong(1);
    }

    public void setHeartBeatTime(Long heartBeatTime) {
        setDataLong(1, heartBeatTime);
    }

    public String getOsInfo() {
        return getDataString(2);
    }

    public void setOsInfo(String osInfo) {
        setDataString(2, osInfo);
    }
121 122 123 124 125 126 127 128 129 130

    public int getAddressId() {
        return getDataInteger(2);
    }

    public void setAddressId(int addressId) {
        setDataInteger(2, addressId);
    }

    public boolean getIsAddress() {
131
        return BooleanUtils.valueToBoolean(getDataInteger(3));
132 133 134
    }

    public void setIsAddress(boolean isAddress) {
135
        setDataInteger(3, BooleanUtils.booleanToValue(isAddress));
136
    }
P
peng-yongsheng 已提交
137
}