Instance.java 4.5 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;
22
import org.apache.skywalking.apm.collector.core.data.RemoteData;
P
peng-yongsheng 已提交
23
import org.apache.skywalking.apm.collector.core.data.StreamData;
24 25
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
26
import org.apache.skywalking.apm.collector.remote.service.RemoteDataRegisterService;
P
peng-yongsheng 已提交
27 28 29 30

/**
 * @author peng-yongsheng
 */
P
peng-yongsheng 已提交
31
public class Instance extends StreamData {
P
peng-yongsheng 已提交
32 33 34 35 36

    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()),
37
        new Column(InstanceTable.COLUMN_APPLICATION_CODE, new CoverOperation()),
P
peng-yongsheng 已提交
38 39 40 41 42 43
    };

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

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

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

    private static final Column[] BYTE_COLUMNS = {};

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

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

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

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

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

P
peng-yongsheng 已提交
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 121 122
    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);
    }
123

124 125 126 127 128 129 130 131
    public String getApplicationCode() {
        return getDataString(3);
    }

    public void setApplicationCode(String applicationCode) {
        setDataString(3, applicationCode);
    }

132 133 134 135 136 137 138 139
    public int getAddressId() {
        return getDataInteger(2);
    }

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

140 141
    public int getIsAddress() {
        return getDataInteger(3);
142 143
    }

144 145
    public void setIsAddress(int isAddress) {
        setDataInteger(3, isAddress);
146
    }
147 148 149 150 151 152

    public static class InstanceCreator implements RemoteDataRegisterService.RemoteDataInstanceCreator {
        @Override public RemoteData createInstance() {
            return new Instance();
        }
    }
P
peng-yongsheng 已提交
153
}