blob: 70354c0f16d08ca8f248fe3a7bff46915a740225 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
|
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.service.duper;
import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.NodeType;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.ServiceType;
import com.yahoo.vespa.service.model.ApplicationInstanceGenerator;
import java.util.Objects;
/**
* @author hakon
*
* TODO: This does not extend InfraApplication because
* 1) It is not deployed same as the other HostedVespaApplications
* 2) ZoneApplication has multiple clusters
*/
public class ZoneApplication {
private ZoneApplication() {}
private static final ApplicationId ZONE_APPLICATION_ID = InfraApplication
.createHostedVespaApplicationId("routing");
private static final ClusterId NODE_ADMIN_CLUSTER_ID = new ClusterId("node-admin");
private static final ClusterId ROUTING_CLUSTER_ID = new ClusterId("routing");
public static ApplicationId getApplicationId() {
return ZONE_APPLICATION_ID;
}
public static TenantName getTenantName() {
return ZONE_APPLICATION_ID.tenant();
}
public static ApplicationName getApplicationName() {
return ZONE_APPLICATION_ID.application();
}
public static NodeType getNodeAdminNodeType() {
return NodeType.host;
}
public static ClusterId getNodeAdminClusterId() {
return NODE_ADMIN_CLUSTER_ID;
}
public static ClusterSpec.Type getNodeAdminClusterSpecType() {
return ClusterSpec.Type.container;
}
public static ClusterSpec.Id getNodeAdminClusterSpecId() {
return new ClusterSpec.Id(getNodeAdminClusterId().s());
}
public static ServiceType getNodeAdminServiceType() {
return ServiceType.CONTAINER;
}
public static int getNodeAdminHealthPort() {
return HostAdminApplication.HOST_ADMIN_HEALT_PORT;
}
public static NodeType getRoutingNodeType() {
return NodeType.proxy;
}
public static ClusterId getRoutingClusterId() {
return ROUTING_CLUSTER_ID;
}
public static ClusterSpec.Type getRoutingClusterSpecType() {
return ClusterSpec.Type.container;
}
public static ClusterSpec.Id getRoutingClusterSpecId() {
return new ClusterSpec.Id(getRoutingClusterId().s());
}
public static ServiceType getRoutingServiceType() {
return ServiceType.CONTAINER;
}
public static int getRoutingHealthPort() {
return 4088;
}
public static boolean isNodeAdminService(ApplicationId applicationId,
ClusterId clusterId,
ServiceType serviceType) {
return Objects.equals(applicationId, getApplicationId()) &&
Objects.equals(serviceType, getNodeAdminServiceType()) &&
Objects.equals(clusterId, getNodeAdminClusterId());
}
/** Whether a {@link ServiceInfo} belongs to the zone application's node-admin cluster. */
public static boolean isNodeAdminServiceInfo(ApplicationId applicationId, ServiceInfo serviceInfo) {
return isNodeAdminService(
applicationId,
ApplicationInstanceGenerator.getClusterId(serviceInfo),
ApplicationInstanceGenerator.toServiceType(serviceInfo));
}
}
|