ServiceInstanceRelation.java 4.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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.
 *
 */

19
package org.apache.skywalking.oap.server.core.source;
20

21 22
import lombok.Getter;
import lombok.Setter;
23 24 25
import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.NodeType;
26

wu-sheng's avatar
wu-sheng 已提交
27
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_RELATION;
28
import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_RELATION_CATALOG_NAME;
wu-sheng's avatar
wu-sheng 已提交
29

30
@ScopeDeclaration(id = SERVICE_INSTANCE_RELATION, name = "ServiceInstanceRelation", catalog = SERVICE_INSTANCE_RELATION_CATALOG_NAME)
wu-sheng's avatar
wu-sheng 已提交
31
@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
32
public class ServiceInstanceRelation extends Source {
33
    private String entityId;
34

35 36
    @Override
    public int scope() {
wu-sheng's avatar
wu-sheng 已提交
37
        return DefaultScopeDefine.SERVICE_INSTANCE_RELATION;
38
    }
39

40 41
    @Override
    public String getEntityId() {
42 43 44 45 46 47 48 49 50
        if (StringUtil.isEmpty(entityId)) {
            entityId = IDManager.ServiceInstanceID.buildRelationId(
                new IDManager.ServiceInstanceID.ServiceInstanceRelationDefine(
                    sourceServiceInstanceId,
                    destServiceInstanceId
                )
            );
        }
        return entityId;
wu-sheng's avatar
wu-sheng 已提交
51 52
    }

53
    @Getter
54
    private String sourceServiceInstanceId;
55
    @Getter
56
    private String sourceServiceId;
57 58
    @Getter
    @Setter
59
    @ScopeDefaultColumn.DefinedByField(columnName = "source_service_name", requireDynamicActive = true)
60
    private String sourceServiceName;
61 62
    @Setter
    private NodeType sourceServiceNodeType;
63 64
    @Getter
    @Setter
65
    @ScopeDefaultColumn.DefinedByField(columnName = "source_service_instance_name", requireDynamicActive = true)
66 67
    private String sourceServiceInstanceName;
    @Getter
68
    private String destServiceInstanceId;
69
    @Getter
70 71 72
    private String destServiceId;
    @Setter
    private NodeType destServiceNodeType;
73 74
    @Getter
    @Setter
75
    @ScopeDefaultColumn.DefinedByField(columnName = "dest_service_name", requireDynamicActive = true)
76 77 78
    private String destServiceName;
    @Getter
    @Setter
79
    @ScopeDefaultColumn.DefinedByField(columnName = "dest_service_instance_name", requireDynamicActive = true)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    private String destServiceInstanceName;
    @Getter
    @Setter
    private String endpoint;
    @Getter
    @Setter
    private int componentId;
    @Getter
    @Setter
    private int latency;
    @Getter
    @Setter
    private boolean status;
    @Getter
    @Setter
    private int responseCode;
    @Getter
    @Setter
    private RequestType type;
    @Getter
    @Setter
    private DetectPoint detectPoint;
G
Gao Hongtao 已提交
102 103 104
    @Getter
    @Setter
    private String tlsMode;
105 106 107
    @Getter
    @Setter
    private SideCar sideCar = new SideCar();
108 109 110
    @Getter
    @Setter
    private TCPInfo tcpInfo = new TCPInfo();
111 112 113 114 115 116 117 118

    @Override
    public void prepare() {
        sourceServiceId = IDManager.ServiceID.buildId(sourceServiceName, sourceServiceNodeType);
        destServiceId = IDManager.ServiceID.buildId(destServiceName, destServiceNodeType);
        sourceServiceInstanceId = IDManager.ServiceInstanceID.buildId(sourceServiceId, sourceServiceInstanceName);
        destServiceInstanceId = IDManager.ServiceInstanceID.buildId(destServiceId, destServiceInstanceName);
    }
119
}