diff options
author | Harald Musum <musum@yahooinc.com> | 2023-06-16 12:46:37 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-06-16 12:46:37 +0200 |
commit | e89ee09abf52b98a6b871065fa1215a15592a34a (patch) | |
tree | fcf8c69841438b745ba2182973ef4497565c97cd /orchestrator | |
parent | ae3e30955bd9031496d9ef466f1a68223184a376 (diff) |
Use ApplicationId instead of ApplicationInstanceReference where possible
Diffstat (limited to 'orchestrator')
7 files changed, 12 insertions, 23 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java index 49fab7522ba..99c2fa11825 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java @@ -380,7 +380,7 @@ public class OrchestratorImpl implements Orchestrator { OrchestratorContext context = OrchestratorContext.createContextForSingleAppOp(clock); ApplicationInstanceReference reference = OrchestratorUtil.toApplicationInstanceReference(appId, serviceMonitor); - ApplicationInstance application = serviceMonitor.getApplication(reference) + ApplicationInstance application = serviceMonitor.getApplication(appId) .orElseThrow(ApplicationIdNotFoundException::new); try (ApplicationLock lock = statusService.lockApplication(context, reference)) { @@ -412,7 +412,7 @@ public class OrchestratorImpl implements Orchestrator { @Override public boolean isQuiescent(ApplicationId id) { try { - ApplicationInstance application = serviceMonitor.getApplication(OrchestratorUtil.toApplicationInstanceReference(id, serviceMonitor)) + ApplicationInstance application = serviceMonitor.getApplication(id) .orElseThrow(ApplicationIdNotFoundException::new); List<ServiceCluster> contentClusters = application.serviceClusters().stream() diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java index 3093a2a9828..c232cd95a2f 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java @@ -14,13 +14,10 @@ import com.yahoo.vespa.applicationmodel.ServiceInstance; import com.yahoo.vespa.applicationmodel.TenantId; import com.yahoo.vespa.service.monitor.ServiceMonitor; -import java.util.Collection; import java.util.List; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static java.util.stream.Collectors.toSet; @@ -91,7 +88,6 @@ public class OrchestratorUtil { } public static ApplicationId toApplicationId(ApplicationInstanceReference appRef) { - String appNameStr = appRef.asString(); String[] appNameParts = appNameStr.split(":"); @@ -99,8 +95,8 @@ public class OrchestratorUtil { // Assume here that first two are tenant and application name. if (appNameParts.length == 2) { return ApplicationId.from(TenantName.from(appNameParts[0]), - ApplicationName.from(appNameParts[1]), - InstanceName.defaultName()); + ApplicationName.from(appNameParts[1]), + InstanceName.defaultName()); } // Other normal application should have 5 parts. @@ -109,8 +105,8 @@ public class OrchestratorUtil { } return ApplicationId.from(TenantName.from(appNameParts[0]), - ApplicationName.from(appNameParts[1]), - InstanceName.from(appNameParts[4])); + ApplicationName.from(appNameParts[1]), + InstanceName.from(appNameParts[4])); } } diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandler.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandler.java index 0964a3f7dd5..67899849def 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandler.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandler.java @@ -98,7 +98,7 @@ public class InstanceRequestHandler extends RestApiRequestHandler<InstanceReques ApplicationInstanceReference instanceId = parseInstanceId(instanceIdString); ApplicationInstance applicationInstance - = serviceMonitor.getApplication(instanceId) + = serviceMonitor.getApplication(OrchestratorUtil.toApplicationId(instanceId)) .orElseThrow(RestApiException.NotFound::new); HostInfos hostInfos = statusService.getHostInfosByApplicationResolver().apply(applicationInstance.reference()); diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java index 853dc17a3fc..689bc32ca6a 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java @@ -153,14 +153,6 @@ public class DummyServiceMonitor implements ServiceMonitor, AntiServiceMonitor { } @Override - public Optional<ApplicationInstance> getApplication(ApplicationInstanceReference reference) { - for (ApplicationInstance app : apps) { - if (app.reference().equals(reference)) return Optional.of(app); - } - return Optional.empty(); - } - - @Override public CriticalRegion disallowDuperModelLockAcquisition(String regionDescription) { return () -> {}; } diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java index 70a8381c9ac..b82ea245261 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java @@ -442,7 +442,7 @@ public class OrchestratorImplTest { ccHost, ServiceStatus.UP))))); - ServiceMonitor serviceMonitor = () -> new ServiceModel(Map.of(reference, applicationInstance)); + ServiceMonitor serviceMonitor = () -> new ServiceModel(Map.of(reference, applicationInstance), zone); ClusterControllerClientFactory clusterControllerClientFactory = mock(ClusterControllerClientFactory.class); ClusterControllerClient fooClient = mock(ClusterControllerClient.class); @@ -508,7 +508,7 @@ public class OrchestratorImplTest { hostName, ServiceStatus.NOT_CHECKED))))); - ServiceMonitor serviceMonitor = () -> new ServiceModel(Map.of(reference, applicationInstance)); + ServiceMonitor serviceMonitor = () -> new ServiceModel(Map.of(reference, applicationInstance), zone); orchestrator = new OrchestratorImpl(new HostedVespaPolicy(new HostedVespaClusterPolicy(flagSource, zone), clusterControllerClientFactory, diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java index f2e2972ae9f..d93a8353fa3 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java @@ -74,7 +74,7 @@ class ModelTestUtils { private final Map<ApplicationInstanceReference, ApplicationInstance> applications = new HashMap<>(); private final ClusterControllerClientFactory clusterControllerClientFactory = new ClusterControllerClientFactoryMock(); private final Map<HostName, HostStatus> hostStatusMap = new HashMap<>(); - private final ServiceMonitor serviceMonitor = () -> new ServiceModel(applications); + private final ServiceMonitor serviceMonitor = () -> new ServiceModel(applications, Zone.defaultZone()); private final StatusService statusService = new ZkStatusService( new MockCurator(), mock(Metric.class), diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java index b9dab4b3aeb..f3f2bb18400 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.orchestrator.resources; import com.yahoo.concurrent.UncheckedTimeoutException; +import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpRequestBuilder; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.jdisc.Metric; @@ -91,7 +92,7 @@ class HostRequestHandlerTest { } private static final ServiceMonitor alwaysEmptyServiceMonitor = new ServiceMonitor() { - private final ServiceModel emptyServiceModel = new ServiceModel(Map.of()); + private final ServiceModel emptyServiceModel = new ServiceModel(Map.of(), Zone.defaultZone()); @Override public ServiceModel getServiceModelSnapshot() { |