aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-12-14 15:11:28 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2016-12-14 15:11:28 +0100
commit0a1ded246aa6c77d2425cfdcbfdd78c602ef3284 (patch)
tree07ce97dc2ec3175c971decd057a7782f84ba1b2f /orchestrator
parent7257ea9fe11d09e7e66f8ab258cad0fb56c94584 (diff)
Nonfunctional changes only
Diffstat (limited to 'orchestrator')
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationIdNotFoundException.java1
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationStateChangeDeniedException.java1
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchHostNameNotFoundException.java5
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchInternalErrorException.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/HostNameNotFoundException.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/InstanceLookupService.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestrationException.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/Orchestrator.java12
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java51
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java39
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ServiceMonitorInstanceLookupService.java18
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/VespaModelUtil.java30
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClient.java5
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientFactory.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImpl.java14
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerJaxRsApi.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateRequest.java1
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateResponse.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/RetryingClusterControllerClientFactory.java18
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactory.java18
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/BatchHostStateChangeDeniedException.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostStateChangeDeniedException.java23
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaPolicy.java76
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/Policy.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ServiceClusterSuspendPolicy.java4
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionResource.java5
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostResource.java15
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostSuspensionResource.java6
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceResource.java20
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/InMemoryStatusService.java21
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/MutableStatusRegistry.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ReadOnlyStatusRegistry.java2
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java36
33 files changed, 216 insertions, 225 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationIdNotFoundException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationIdNotFoundException.java
index d12bd66bc86..48698685894 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationIdNotFoundException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationIdNotFoundException.java
@@ -15,4 +15,5 @@ public class ApplicationIdNotFoundException extends Exception {
public ApplicationIdNotFoundException(String reason) {
super(reason);
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationStateChangeDeniedException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationStateChangeDeniedException.java
index 0ed379e5ece..370e38a232c 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationStateChangeDeniedException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ApplicationStateChangeDeniedException.java
@@ -19,4 +19,5 @@ public class ApplicationStateChangeDeniedException extends Exception {
super();
this.reason = reason;
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchHostNameNotFoundException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchHostNameNotFoundException.java
index 6da27678b21..9e364b396ab 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchHostNameNotFoundException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchHostNameNotFoundException.java
@@ -6,10 +6,11 @@ import com.yahoo.vespa.applicationmodel.HostName;
import java.util.List;
public class BatchHostNameNotFoundException extends OrchestrationException {
+
public BatchHostNameNotFoundException(HostName parentHostname,
List<HostName> hostNames,
HostNameNotFoundException e) {
- super("Failed to suspend " + hostNames + " with parent host "
- + parentHostname + ": " + e.getMessage(), e);
+ super("Failed to suspend " + hostNames + " with parent host " + parentHostname + ": " + e.getMessage(), e);
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchInternalErrorException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchInternalErrorException.java
index 7bd0237d37b..0762caea742 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchInternalErrorException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/BatchInternalErrorException.java
@@ -6,10 +6,12 @@ import com.yahoo.vespa.applicationmodel.HostName;
import java.util.List;
public class BatchInternalErrorException extends OrchestrationException {
+
public BatchInternalErrorException(HostName parentHostname,
List<HostName> orderedHostNames,
RuntimeException e) {
super("Failed to suspend " + orderedHostNames + " with parent host "
+ parentHostname + ": " + e.getMessage(), e);
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/HostNameNotFoundException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/HostNameNotFoundException.java
index 9a1b5c5b6b0..97679d69da0 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/HostNameNotFoundException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/HostNameNotFoundException.java
@@ -9,7 +9,9 @@ import com.yahoo.vespa.applicationmodel.HostName;
* @author smorgrav
*/
public class HostNameNotFoundException extends OrchestrationException {
+
public HostNameNotFoundException(HostName hostName) {
super("Hostname " + hostName + " not found in any instances");
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/InstanceLookupService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/InstanceLookupService.java
index 11221e3a464..33da2237e1c 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/InstanceLookupService.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/InstanceLookupService.java
@@ -13,7 +13,9 @@ import java.util.Set;
* @author oyving
*/
public interface InstanceLookupService {
+
Optional<ApplicationInstance<ServiceMonitorStatus>> findInstanceById(ApplicationInstanceReference applicationInstanceReference);
Optional<ApplicationInstance<ServiceMonitorStatus>> findInstanceByHost(HostName hostName);
Set<ApplicationInstanceReference> knownInstances();
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestrationException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestrationException.java
index 600fe8bfe8b..570606081ca 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestrationException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestrationException.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.orchestrator;
import java.util.Arrays;
public class OrchestrationException extends Exception {
+
public OrchestrationException(Throwable cause) {
super(cause);
}
@@ -26,4 +27,5 @@ public class OrchestrationException extends Exception {
Arrays.stream(suppressedThrowables).forEach(t -> builder.append("; With suppressed throwable " + t));
return builder.toString();
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/Orchestrator.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/Orchestrator.java
index 0adafaaa628..222b28dae16 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/Orchestrator.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/Orchestrator.java
@@ -38,7 +38,7 @@ public interface Orchestrator {
* @return The enum describing the current state.
* @throws HostNameNotFoundException if hostName is unrecognized (in node repo)
*/
- HostStatus getNodeStatus(final HostName hostName) throws HostNameNotFoundException;
+ HostStatus getNodeStatus(HostName hostName) throws HostNameNotFoundException;
/**
* Resume normal operation for this host.
@@ -47,7 +47,7 @@ public interface Orchestrator {
* @throws HostStateChangeDeniedException if the request cannot be meet due to policy constraints.
* @throws HostNameNotFoundException if the hostName is not recognized in the system (node repo)
*/
- void resume(final HostName hostName) throws HostStateChangeDeniedException, HostNameNotFoundException;
+ void resume(HostName hostName) throws HostStateChangeDeniedException, HostNameNotFoundException;
/**
* Suspend normal operations for this host.
@@ -56,7 +56,7 @@ public interface Orchestrator {
* @throws HostStateChangeDeniedException if the request cannot be meet due to policy constraints.
* @throws HostNameNotFoundException if the hostName is not recognized in the system (node repo)
*/
- void suspend(final HostName hostName) throws HostStateChangeDeniedException, HostNameNotFoundException;
+ void suspend(HostName hostName) throws HostStateChangeDeniedException, HostNameNotFoundException;
/**
* Get the orchestrator status of the application instance.
@@ -64,7 +64,7 @@ public interface Orchestrator {
* @param appId Identifier of the application to check
* @return The enum describing the current state.
*/
- ApplicationInstanceStatus getApplicationInstanceStatus(final ApplicationId appId) throws ApplicationIdNotFoundException;
+ ApplicationInstanceStatus getApplicationInstanceStatus(ApplicationId appId) throws ApplicationIdNotFoundException;
/**
* Returns all application instances that are suspended. The intention is to use this
@@ -79,7 +79,7 @@ public interface Orchestrator {
*
* @param appId Identifier of the application to resume
*/
- void resume(final ApplicationId appId) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException;
+ void resume(ApplicationId appId) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException;
/**
@@ -88,7 +88,7 @@ public interface Orchestrator {
*
* @param appId Identifier of the application to resume
*/
- void suspend(final ApplicationId appId) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException;
+ void suspend(ApplicationId appId) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException;
/**
* Suspend all hosts. On failure, all hosts are resumed before exiting the method with an exception.
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 7197c9bcd43..c77d03ea683 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorImpl.java
@@ -50,11 +50,10 @@ public class OrchestratorImpl implements Orchestrator {
private final ClusterControllerClientFactory clusterControllerClientFactory;
@Inject
- public OrchestratorImpl(
- final ClusterControllerClientFactory clusterControllerClientFactory,
- final StatusService statusService,
- final OrchestratorConfig orchestratorConfig,
- final InstanceLookupService instanceLookupService)
+ public OrchestratorImpl(ClusterControllerClientFactory clusterControllerClientFactory,
+ StatusService statusService,
+ OrchestratorConfig orchestratorConfig,
+ InstanceLookupService instanceLookupService)
{
this(new HostedVespaPolicy(clusterControllerClientFactory),
clusterControllerClientFactory,
@@ -63,12 +62,11 @@ public class OrchestratorImpl implements Orchestrator {
orchestratorConfig.serviceMonitorConvergenceLatencySeconds());
}
- public OrchestratorImpl(
- final Policy policy,
- final ClusterControllerClientFactory clusterControllerClientFactory,
- final StatusService statusService,
- final InstanceLookupService instanceLookupService,
- final int serviceMonitorConvergenceLatencySeconds)
+ public OrchestratorImpl(Policy policy,
+ ClusterControllerClientFactory clusterControllerClientFactory,
+ StatusService statusService,
+ InstanceLookupService instanceLookupService,
+ int serviceMonitorConvergenceLatencySeconds)
{
this.policy = policy;
this.clusterControllerClientFactory = clusterControllerClientFactory;
@@ -134,8 +132,7 @@ public class OrchestratorImpl implements Orchestrator {
}
@Override
- public ApplicationInstanceStatus getApplicationInstanceStatus(
- final ApplicationId appId) throws ApplicationIdNotFoundException {
+ public ApplicationInstanceStatus getApplicationInstanceStatus(ApplicationId appId) throws ApplicationIdNotFoundException {
ApplicationInstanceReference appRef = OrchestratorUtil.toApplicationInstanceReference(appId,instanceLookupService);
return statusService.forApplicationInstance(appRef).getApplicationInstanceStatus();
}
@@ -242,10 +239,8 @@ public class OrchestratorImpl implements Orchestrator {
return orderedHostNames;
}
- private int compareHostNamesForSuspend(
- HostName leftHostname,
- HostName rightHostname,
- Map<HostName, ApplicationInstanceReference> applicationReferences) {
+ private int compareHostNamesForSuspend(HostName leftHostname, HostName rightHostname,
+ Map<HostName, ApplicationInstanceReference> applicationReferences) {
ApplicationInstanceReference leftApplicationReference = applicationReferences.get(leftHostname);
assert leftApplicationReference != null;
@@ -261,17 +256,12 @@ public class OrchestratorImpl implements Orchestrator {
return leftHostname.toString().compareTo(rightHostname.toString());
}
- private HostStatus getNodeStatus(
- final ApplicationInstanceReference applicationRef,
- final HostName hostName) {
+ private HostStatus getNodeStatus(ApplicationInstanceReference applicationRef, HostName hostName) {
return statusService.forApplicationInstance(applicationRef).getHostStatus(hostName);
}
- private void setApplicationStatus(
- final ApplicationId appId,
- final ApplicationInstanceStatus status) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException{
-
-
+ private void setApplicationStatus(ApplicationId appId, ApplicationInstanceStatus status)
+ throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException{
ApplicationInstanceReference appRef = OrchestratorUtil.toApplicationInstanceReference(appId, instanceLookupService);
try (MutableStatusRegistry statusRegistry =
statusService.lockApplicationInstance_forCurrentThreadOnly(appRef)) {
@@ -296,10 +286,9 @@ public class OrchestratorImpl implements Orchestrator {
}
}
- private void setClusterStateInController(
- final ApplicationInstance<ServiceMonitorStatus> application,
- final ClusterControllerState state) throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException {
-
+ private void setClusterStateInController(ApplicationInstance<ServiceMonitorStatus> application,
+ ClusterControllerState state)
+ throws ApplicationStateChangeDeniedException, ApplicationIdNotFoundException {
// Get all content clusters for this application
Set<ClusterId> contentClusterIds = application.serviceClusters().stream()
.filter(VespaModelUtil::isContent)
@@ -310,7 +299,7 @@ public class OrchestratorImpl implements Orchestrator {
log.log(LogLevel.INFO, String.format("Setting content clusters %s for application %s to %s",
contentClusterIds,application.applicationInstanceId(),state));
for (ClusterId clusterId : contentClusterIds) {
- final ClusterControllerClient client = clusterControllerClientFactory.createClient(
+ ClusterControllerClient client = clusterControllerClientFactory.createClient(
VespaModelUtil.getClusterControllerInstances(application, clusterId),
clusterId.s());
try {
@@ -335,7 +324,7 @@ public class OrchestratorImpl implements Orchestrator {
return instanceLookupService.findInstanceById(appRef).orElseThrow(ApplicationIdNotFoundException::new);
}
- private static void sleep(final long time, final TimeUnit timeUnit) {
+ private static void sleep(long time, TimeUnit timeUnit) {
try {
Thread.sleep(timeUnit.toMillis(time));
} catch (InterruptedException e) {
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 e67e7564745..565a96de13b 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java
@@ -34,54 +34,48 @@ import static java.util.stream.Collectors.toSet;
* @author bakksjo
*/
public class OrchestratorUtil {
+
// Utility class, not to be instantiated.
private OrchestratorUtil() {}
- public static Set<HostName> getHostsUsedByApplicationInstance(final ApplicationInstance<?> applicationInstance) {
+ public static Set<HostName> getHostsUsedByApplicationInstance(ApplicationInstance<?> applicationInstance) {
return applicationInstance.serviceClusters().stream()
.flatMap(serviceCluster -> getHostsUsedByServiceCluster(serviceCluster).stream())
.collect(toSet());
}
- public static Set<HostName> getHostsUsedByServiceCluster(final ServiceCluster<?> serviceCluster) {
+ public static Set<HostName> getHostsUsedByServiceCluster(ServiceCluster<?> serviceCluster) {
return serviceCluster.serviceInstances().stream()
.map(ServiceInstance::hostName)
.collect(toSet());
}
- public static <T> Set<ServiceCluster<T>> getServiceClustersUsingHost(
- final Collection<ServiceCluster<T>> serviceClusters,
- final HostName hostName) {
+ public static <T> Set<ServiceCluster<T>> getServiceClustersUsingHost(Collection<ServiceCluster<T>> serviceClusters,
+ HostName hostName) {
return serviceClusters.stream()
.filter(serviceCluster -> hasServiceInstanceOnHost(serviceCluster, hostName))
.collect(toSet());
}
- public static Map<HostName, HostStatus> getHostStatusMap(
- final Collection<HostName> hosts,
- final ReadOnlyStatusRegistry hostStatusService) {
+ public static Map<HostName, HostStatus> getHostStatusMap(Collection<HostName> hosts,
+ ReadOnlyStatusRegistry hostStatusService) {
return hosts.stream()
.collect(Collectors.toMap(
hostName -> hostName,
hostName -> hostStatusService.getHostStatus(hostName)));
}
- private static boolean hasServiceInstanceOnHost(
- final ServiceCluster<?> serviceCluster,
- final HostName hostName) {
+ private static boolean hasServiceInstanceOnHost(ServiceCluster<?> serviceCluster, HostName hostName) {
return serviceInstancesOnHost(serviceCluster, hostName).count() > 0;
}
- public static <T> Stream<ServiceInstance<T>> serviceInstancesOnHost(
- final ServiceCluster<T> serviceCluster,
- final HostName hostName) {
+ public static <T> Stream<ServiceInstance<T>> serviceInstancesOnHost(ServiceCluster<T> serviceCluster,
+ HostName hostName) {
return serviceCluster.serviceInstances().stream()
.filter(instance -> instance.hostName().equals(hostName));
}
- public static <K, V1, V2> Map<K, V2> mapValues(
- final Map<K, V1> map,
- final Function<V1, V2> valueConverter) {
+ public static <K, V1, V2> Map<K, V2> mapValues(Map<K, V1> map, Function<V1, V2> valueConverter) {
return map.entrySet().stream()
.collect(toMap(Map.Entry::getKey, entry -> valueConverter.apply(entry.getValue())));
}
@@ -89,22 +83,22 @@ public class OrchestratorUtil {
private static final Pattern APPLICATION_INSTANCE_REFERENCE_REST_FORMAT_PATTERN = Pattern.compile("^([^:]+):(.+)$");
/** Returns an ApplicationInstanceReference constructed from the serialized format used in the REST API. */
- public static ApplicationInstanceReference parseAppInstanceReference(final String restFormat) {
+ public static ApplicationInstanceReference parseAppInstanceReference(String restFormat) {
if (restFormat == null) {
throw new IllegalArgumentException("Could not construct instance id from null string");
}
- final Matcher matcher = APPLICATION_INSTANCE_REFERENCE_REST_FORMAT_PATTERN.matcher(restFormat);
+ Matcher matcher = APPLICATION_INSTANCE_REFERENCE_REST_FORMAT_PATTERN.matcher(restFormat);
if (!matcher.matches()) {
throw new IllegalArgumentException("Could not construct instance id from string \"" + restFormat +"\"");
}
- final TenantId tenantId = new TenantId(matcher.group(1));
- final ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId(matcher.group(2));
+ TenantId tenantId = new TenantId(matcher.group(1));
+ ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId(matcher.group(2));
return new ApplicationInstanceReference(tenantId, applicationInstanceId);
}
- public static String toRestApiFormat(final ApplicationInstanceReference applicationInstanceReference) {
+ public static String toRestApiFormat(ApplicationInstanceReference applicationInstanceReference) {
return applicationInstanceReference.tenantId() + ":" + applicationInstanceReference.applicationInstanceId();
}
@@ -152,4 +146,5 @@ public class OrchestratorUtil {
ApplicationName.from(appNameParts[1]),
InstanceName.from(appNameParts[4]));
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ServiceMonitorInstanceLookupService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ServiceMonitorInstanceLookupService.java
index ea64add77b1..f8f9b02547f 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ServiceMonitorInstanceLookupService.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/ServiceMonitorInstanceLookupService.java
@@ -20,26 +20,26 @@ import java.util.stream.Collectors;
* @author bakksjo
*/
public class ServiceMonitorInstanceLookupService implements InstanceLookupService {
+
private final SlobrokAndConfigIntersector slobrokAndConfigIntersector;
@Inject
- public ServiceMonitorInstanceLookupService(final SlobrokAndConfigIntersector slobrokAndConfigIntersector) {
+ public ServiceMonitorInstanceLookupService(SlobrokAndConfigIntersector slobrokAndConfigIntersector) {
this.slobrokAndConfigIntersector = slobrokAndConfigIntersector;
}
@Override
- public Optional<ApplicationInstance<ServiceMonitorStatus>> findInstanceById(
- final ApplicationInstanceReference applicationInstanceReference) {
- final Map<ApplicationInstanceReference, ApplicationInstance<ServiceMonitorStatus>> instanceMap
+ public Optional<ApplicationInstance<ServiceMonitorStatus>> findInstanceById(ApplicationInstanceReference applicationInstanceReference) {
+ Map<ApplicationInstanceReference, ApplicationInstance<ServiceMonitorStatus>> instanceMap
= slobrokAndConfigIntersector.queryStatusOfAllApplicationInstances();
return Optional.ofNullable(instanceMap.get(applicationInstanceReference));
}
@Override
public Optional<ApplicationInstance<ServiceMonitorStatus>> findInstanceByHost(HostName hostName) {
- final Map<ApplicationInstanceReference, ApplicationInstance<ServiceMonitorStatus>> instanceMap
+ Map<ApplicationInstanceReference, ApplicationInstance<ServiceMonitorStatus>> instanceMap
= slobrokAndConfigIntersector.queryStatusOfAllApplicationInstances();
- final List<ApplicationInstance<ServiceMonitorStatus>> applicationInstancesUsingHost = instanceMap.entrySet().stream()
+ List<ApplicationInstance<ServiceMonitorStatus>> applicationInstancesUsingHost = instanceMap.entrySet().stream()
.filter(entry -> applicationInstanceUsesHost(entry.getValue(), hostName))
.map(Map.Entry::getValue)
.collect(Collectors.toList());
@@ -59,13 +59,13 @@ public class ServiceMonitorInstanceLookupService implements InstanceLookupServic
return slobrokAndConfigIntersector.queryStatusOfAllApplicationInstances().keySet();
}
- private static boolean applicationInstanceUsesHost(
- final ApplicationInstance<ServiceMonitorStatus> applicationInstance,
- final HostName hostName) {
+ private static boolean applicationInstanceUsesHost(ApplicationInstance<ServiceMonitorStatus> applicationInstance,
+ HostName hostName) {
return applicationInstance.serviceClusters().stream()
.anyMatch(serviceCluster ->
serviceCluster.serviceInstances().stream()
.anyMatch(serviceInstance ->
serviceInstance.hostName().equals(hostName)));
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/VespaModelUtil.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/VespaModelUtil.java
index e16ccdca5b7..fd210a901d5 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/VespaModelUtil.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/VespaModelUtil.java
@@ -28,6 +28,7 @@ import static com.yahoo.collections.CollectionUtil.first;
* @author hakonhall
*/
public class VespaModelUtil {
+
private static final Logger log = Logger.getLogger(VespaModelUtil.class.getName());
public static final ClusterId ADMIN_CLUSTER_ID = new ClusterId("admin");
@@ -39,7 +40,7 @@ public class VespaModelUtil {
public static final ServiceType STORAGENODE_SERVICE_TYPE = new ServiceType("storagenode");
// @return true iff the service cluster refers to a cluster controller service cluster.
- public static boolean isClusterController(final ServiceCluster<?> cluster) {
+ public static boolean isClusterController(ServiceCluster<?> cluster) {
return CLUSTER_CONTROLLER_SERVICE_TYPE.equals(cluster.serviceType());
}
@@ -56,7 +57,7 @@ public class VespaModelUtil {
/**
* @return true iff the service cluster is a content service cluster.
*/
- public static boolean isContent(final ServiceCluster<?> cluster) {
+ public static boolean isContent(ServiceCluster<?> cluster) {
return DISTRIBUTOR_SERVICE_TYPE.equals(cluster.serviceType()) ||
SEARCHNODE_SERVICE_TYPE.equals(cluster.serviceType()) ||
STORAGENODE_SERVICE_TYPE.equals(cluster.serviceType());
@@ -65,11 +66,10 @@ public class VespaModelUtil {
/**
* @return The set of all Cluster Controller service instances for the application.
*/
- public static <T> Set<ServiceInstance<T>> getClusterControllerInstances(
- ApplicationInstance<T> application,
- ClusterId contentClusterId)
+ public static <T> Set<ServiceInstance<T>> getClusterControllerInstances(ApplicationInstance<T> application,
+ ClusterId contentClusterId)
{
- final Set<ServiceCluster<T>> controllerClusters = getClusterControllerServiceClusters(application);
+ Set<ServiceCluster<T>> controllerClusters = getClusterControllerServiceClusters(application);
Collection<ServiceCluster<T>> controllerClustersForContentCluster = filter(controllerClusters, contentClusterId);
@@ -88,9 +88,8 @@ public class VespaModelUtil {
}
}
- private static <T> Collection<ServiceCluster<T>> filter(
- Set<ServiceCluster<T>> controllerClusters,
- ClusterId contentClusterId) {
+ private static <T> Collection<ServiceCluster<T>> filter(Set<ServiceCluster<T>> controllerClusters,
+ ClusterId contentClusterId) {
ClusterId clusterControllerClusterId = new ClusterId(contentClusterId.s() + "-controllers");
return controllerClusters.stream().
@@ -98,8 +97,7 @@ public class VespaModelUtil {
collect(Collectors.toList());
}
- public static <T> Set<ServiceCluster<T>> getClusterControllerServiceClusters(
- final ApplicationInstance<T> application) {
+ public static <T> Set<ServiceCluster<T>> getClusterControllerServiceClusters(ApplicationInstance<T> application) {
return application.serviceClusters().stream()
.filter(VespaModelUtil::isClusterController)
.collect(Collectors.toSet());
@@ -112,7 +110,7 @@ public class VespaModelUtil {
*/
public static HostName getControllerHostName(ApplicationInstance<?> application, ClusterId contentClusterId) {
// It happens that the master Cluster Controller is the one with the lowest index, if up.
- final ServiceInstance<?> serviceInstance = getClusterControllerInstances(application, contentClusterId)
+ ServiceInstance<?> serviceInstance = getClusterControllerInstances(application, contentClusterId)
.stream()
.min(Comparator.comparing(instance -> getClusterControllerIndex(instance.configId())))
.orElseThrow(() ->
@@ -169,8 +167,8 @@ public class VespaModelUtil {
return getStorageNodeIndex(storageNode.get().configId());
}
- public static <T> Optional<ServiceInstance<T>> getStorageNodeAtHost(
- ApplicationInstance<T> application, HostName hostName) {
+ public static <T> Optional<ServiceInstance<T>> getStorageNodeAtHost(ApplicationInstance<T> application,
+ HostName hostName) {
Set<ServiceInstance<T>> storageNodesOnHost = application.serviceClusters().stream()
.filter(VespaModelUtil::isStorage)
.flatMap(cluster -> cluster.serviceInstances().stream())
@@ -191,8 +189,7 @@ public class VespaModelUtil {
}
// See getClusterControllerIndex()
- private static final Pattern CONTROLLER_INDEX_PATTERN =
- Pattern.compile("admin/cluster-controllers/(\\d+)");
+ private static final Pattern CONTROLLER_INDEX_PATTERN = Pattern.compile("admin/cluster-controllers/(\\d+)");
/**
* @param configId Must be of the form admin/cluster-controllers/2
@@ -224,4 +221,5 @@ public class VespaModelUtil {
return Integer.valueOf(matcher.group(1));
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClient.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClient.java
index 9d70c90fabd..9de7bfab627 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClient.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClient.java
@@ -13,12 +13,13 @@ public interface ClusterControllerClient {
*
* @throws IOException if there was a problem communicating with the cluster controller
*/
- ClusterControllerStateResponse setNodeState(final int storageNodeIndex, final ClusterControllerState wantedState) throws IOException;
+ ClusterControllerStateResponse setNodeState(int storageNodeIndex, ClusterControllerState wantedState) throws IOException;
/**
* Requests that a cluster controller sets all nodes in the cluster to the requested state.
*
* @throws IOException if there was a problem communicating with the cluster controller
*/
- ClusterControllerStateResponse setApplicationState(final ClusterControllerState wantedState) throws IOException;
+ ClusterControllerStateResponse setApplicationState(ClusterControllerState wantedState) throws IOException;
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientFactory.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientFactory.java
index 22033daa72d..e25957d3eaf 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientFactory.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientFactory.java
@@ -9,5 +9,7 @@ import java.util.Collection;
* @author bakksjo
*/
public interface ClusterControllerClientFactory {
+
ClusterControllerClient createClient(Collection<? extends ServiceInstance<?>> clusterControllers, String clusterName);
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImpl.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImpl.java
index 97612d5309c..01ae6dadfc7 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImpl.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImpl.java
@@ -11,14 +11,14 @@ import java.io.IOException;
* @author smorgrav
*/
public class ClusterControllerClientImpl implements ClusterControllerClient{
+
public static final String REQUEST_REASON = "Orchestrator";
private final JaxRsStrategy<ClusterControllerJaxRsApi> clusterControllerApi;
private final String clusterName;
- public ClusterControllerClientImpl(
- final JaxRsStrategy<ClusterControllerJaxRsApi> clusterControllerApi,
- final String clusterName) {
+ public ClusterControllerClientImpl(JaxRsStrategy<ClusterControllerJaxRsApi> clusterControllerApi,
+ String clusterName) {
this.clusterName = clusterName;
this.clusterControllerApi = clusterControllerApi;
}
@@ -29,14 +29,14 @@ public class ClusterControllerClientImpl implements ClusterControllerClient{
* @throws IOException if there was a problem communicating with the cluster controller
*/
@Override
- public ClusterControllerStateResponse setNodeState(final int storageNodeIndex, final ClusterControllerState wantedState) throws IOException {
- final ClusterControllerStateRequest.State state = new ClusterControllerStateRequest.State(wantedState, REQUEST_REASON);
- final ClusterControllerStateRequest stateRequest = new ClusterControllerStateRequest(state, ClusterControllerStateRequest.Condition.SAFE);
+ public ClusterControllerStateResponse setNodeState(int storageNodeIndex, ClusterControllerState wantedState) throws IOException {
+ ClusterControllerStateRequest.State state = new ClusterControllerStateRequest.State(wantedState, REQUEST_REASON);
+ ClusterControllerStateRequest stateRequest = new ClusterControllerStateRequest(state, ClusterControllerStateRequest.Condition.SAFE);
try {
return clusterControllerApi.apply(api -> api.setNodeState(clusterName, storageNodeIndex, stateRequest));
} catch (IOException e) {
- final String message = String.format(
+ String message = String.format(
"Giving up setting %s for storage node with index %d in cluster %s",
stateRequest,
storageNodeIndex,
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerJaxRsApi.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerJaxRsApi.java
index f4f3e166c15..c0f901bc34f 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerJaxRsApi.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerJaxRsApi.java
@@ -12,6 +12,7 @@ import javax.ws.rs.core.MediaType;
* @author hakonhall
*/
public interface ClusterControllerJaxRsApi {
+
@POST
@Path("/cluster/v2/{clusterName}/storage/{storageNodeIndex}")
@Consumes(MediaType.APPLICATION_JSON)
@@ -28,4 +29,5 @@ public interface ClusterControllerJaxRsApi {
ClusterControllerStateResponse setClusterState(
@PathParam("clusterName") String clusterName,
ClusterControllerStateRequest request);
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateRequest.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateRequest.java
index a7680d9659d..2ea489337d8 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateRequest.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateRequest.java
@@ -92,4 +92,5 @@ public class ClusterControllerStateRequest {
public enum Condition {
FORCE, SAFE;
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateResponse.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateResponse.java
index 6036cad9aaa..f2a49ffa306 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateResponse.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerStateResponse.java
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* @author hakonhall
*/
public class ClusterControllerStateResponse {
+
@JsonProperty("wasModified")
public final boolean wasModified;
@@ -22,4 +23,5 @@ public class ClusterControllerStateResponse {
this.wasModified = wasModified;
this.reason = reason;
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/RetryingClusterControllerClientFactory.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/RetryingClusterControllerClientFactory.java
index 1f01765b485..90690e345fe 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/RetryingClusterControllerClientFactory.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/RetryingClusterControllerClientFactory.java
@@ -17,6 +17,7 @@ import java.util.stream.Collectors;
* @author bakksjo
*/
public class RetryingClusterControllerClientFactory implements ClusterControllerClientFactory {
+
// TODO: Figure this port out dynamically.
public static final int HARDCODED_CLUSTERCONTROLLER_PORT = 19050;
public static final String CLUSTERCONTROLLER_API_PATH = "/";
@@ -27,26 +28,23 @@ public class RetryingClusterControllerClientFactory implements ClusterController
@Inject
public RetryingClusterControllerClientFactory() {
- this(new JerseyJaxRsClientFactory(
- CLUSTER_CONTROLLER_CONNECT_TIMEOUT_MS,
- CLUSTER_CONTROLLER_READ_TIMEOUT_MS));
+ this(new JerseyJaxRsClientFactory(CLUSTER_CONTROLLER_CONNECT_TIMEOUT_MS, CLUSTER_CONTROLLER_READ_TIMEOUT_MS));
}
- public RetryingClusterControllerClientFactory(
- final JaxRsClientFactory jaxRsClientFactory) {
+ public RetryingClusterControllerClientFactory(JaxRsClientFactory jaxRsClientFactory) {
this.jaxRsClientFactory = jaxRsClientFactory;
}
@Override
- public ClusterControllerClient createClient(
- final Collection<? extends ServiceInstance<?>> clusterControllers,
- final String clusterName) {
- final Set<HostName> hostNames = clusterControllers.stream()
+ public ClusterControllerClient createClient(Collection<? extends ServiceInstance<?>> clusterControllers,
+ String clusterName) {
+ Set<HostName> hostNames = clusterControllers.stream()
.map(ServiceInstance::hostName)
.collect(Collectors.toSet());
- final JaxRsStrategy<ClusterControllerJaxRsApi> jaxRsApi
+ JaxRsStrategy<ClusterControllerJaxRsApi> jaxRsApi
= new JaxRsStrategyFactory(hostNames, HARDCODED_CLUSTERCONTROLLER_PORT, jaxRsClientFactory)
.apiWithRetries(ClusterControllerJaxRsApi.class, CLUSTERCONTROLLER_API_PATH);
return new ClusterControllerClientImpl(jaxRsApi, clusterName);
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactory.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactory.java
index a4688a19134..8a245edd187 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactory.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactory.java
@@ -18,6 +18,7 @@ import static com.yahoo.vespa.orchestrator.VespaModelUtil.getClusterControllerIn
* @author bakksjo
*/
public class SingleInstanceClusterControllerClientFactory implements ClusterControllerClientFactory {
+
public static final int CLUSTERCONTROLLER_HARDCODED_PORT = 19050;
public static final String CLUSTERCONTROLLER_API_PATH = "/";
@@ -29,26 +30,24 @@ public class SingleInstanceClusterControllerClientFactory implements ClusterCont
private JaxRsClientFactory jaxRsClientFactory;
- public SingleInstanceClusterControllerClientFactory(
- final JaxRsClientFactory jaxRsClientFactory) {
+ public SingleInstanceClusterControllerClientFactory(JaxRsClientFactory jaxRsClientFactory) {
this.jaxRsClientFactory = jaxRsClientFactory;
}
@Override
- public ClusterControllerClient createClient(
- final Collection<? extends ServiceInstance<?>> clusterControllers,
- final String clusterName) {
- final ServiceInstance<?> serviceInstance = clusterControllers.stream()
+ public ClusterControllerClient createClient(Collection<? extends ServiceInstance<?>> clusterControllers,
+ String clusterName) {
+ ServiceInstance<?> serviceInstance = clusterControllers.stream()
.min(CLUSTER_CONTROLLER_INDEX_COMPARATOR)
.orElseThrow(() -> new IllegalArgumentException("No cluster controller instances found"));
- final HostName controllerHostName = serviceInstance.hostName();
- final int port = CLUSTERCONTROLLER_HARDCODED_PORT; // TODO: Get this from service monitor.
+ HostName controllerHostName = serviceInstance.hostName();
+ int port = CLUSTERCONTROLLER_HARDCODED_PORT; // TODO: Get this from service monitor.
log.log(LogLevel.DEBUG, () ->
"For cluster '" + clusterName + "' with controllers " + clusterControllers
+ ", creating api client for " + controllerHostName.s() + ":" + port);
- final JaxRsStrategy<ClusterControllerJaxRsApi> strategy = new NoRetryJaxRsStrategy<>(
+ JaxRsStrategy<ClusterControllerJaxRsApi> strategy = new NoRetryJaxRsStrategy<>(
controllerHostName,
port,
jaxRsClientFactory,
@@ -57,4 +56,5 @@ public class SingleInstanceClusterControllerClientFactory implements ClusterCont
return new ClusterControllerClientImpl(strategy, clusterName);
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/BatchHostStateChangeDeniedException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/BatchHostStateChangeDeniedException.java
index affe9557013..15bc61a3019 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/BatchHostStateChangeDeniedException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/BatchHostStateChangeDeniedException.java
@@ -7,6 +7,7 @@ import com.yahoo.vespa.orchestrator.OrchestrationException;
import java.util.List;
public class BatchHostStateChangeDeniedException extends OrchestrationException {
+
public BatchHostStateChangeDeniedException(HostName parentHostname,
List<HostName> orderedHostNames,
HostStateChangeDeniedException e) {
@@ -14,4 +15,5 @@ public class BatchHostStateChangeDeniedException extends OrchestrationException
+ parentHostname + ": " + e.getMessage(), e);
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostStateChangeDeniedException.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostStateChangeDeniedException.java
index 91ea4c70663..ac1eca310ae 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostStateChangeDeniedException.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostStateChangeDeniedException.java
@@ -9,34 +9,26 @@ import com.yahoo.vespa.orchestrator.OrchestrationException;
* @author bakksjo
*/
public class HostStateChangeDeniedException extends OrchestrationException {
+
private final String constraintName;
private final ServiceType serviceType;
- public HostStateChangeDeniedException(
- final HostName hostName,
- final String constraintName,
- final ServiceType serviceType,
- final String message) {
+ public HostStateChangeDeniedException(HostName hostName, String constraintName,
+ ServiceType serviceType, String message) {
super(createMessage(hostName, constraintName, serviceType, message));
this.constraintName = constraintName;
this.serviceType = serviceType;
}
- public HostStateChangeDeniedException(
- final HostName hostName,
- final String constraintName,
- final ServiceType serviceType,
- final String message,
- final Throwable cause) {
+ public HostStateChangeDeniedException(HostName hostName, String constraintName,
+ ServiceType serviceType, String message, Throwable cause) {
super(createMessage(hostName, constraintName, serviceType, message), cause);
this.constraintName = constraintName;
this.serviceType = serviceType;
}
- private static String createMessage(final HostName hostName,
- final String constraintName,
- final ServiceType serviceType,
- final String message) {
+ private static String createMessage(HostName hostName, String constraintName,
+ ServiceType serviceType, String message) {
return "Changing the state of host " + hostName + " would violate " + constraintName
+ " for service type " + serviceType + ": " + message;
}
@@ -48,4 +40,5 @@ public class HostStateChangeDeniedException extends OrchestrationException {
public ServiceType getServiceType() {
return serviceType;
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaPolicy.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaPolicy.java
index 29a6efd9b87..a85de34097f 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaPolicy.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaPolicy.java
@@ -52,24 +52,23 @@ public class HostedVespaPolicy implements Policy {
@Override
- public void grantSuspensionRequest(
- final ApplicationInstance<ServiceMonitorStatus> applicationInstance,
- final HostName hostName,
- final MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException {
+ public void grantSuspensionRequest(ApplicationInstance<ServiceMonitorStatus> applicationInstance,
+ HostName hostName,
+ MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException {
Set<ServiceCluster<ServiceMonitorStatus>> serviceClustersOnHost =
getServiceClustersUsingHost(applicationInstance.serviceClusters(), hostName);
- final Map<HostName, HostStatus> hostStatusMap = getHostStatusMap(
+ Map<HostName, HostStatus> hostStatusMap = getHostStatusMap(
getHostsUsedByApplicationInstance(applicationInstance),
hostStatusService);
boolean hasUpStorageInstance = false;
- for (final ServiceCluster<ServiceMonitorStatus> serviceCluster : serviceClustersOnHost) {
- final Set<ServiceInstance<ServiceMonitorStatus>> instancesOnThisHost;
- final Set<ServiceInstance<ServiceMonitorStatus>> instancesOnOtherHosts;
+ for (ServiceCluster<ServiceMonitorStatus> serviceCluster : serviceClustersOnHost) {
+ Set<ServiceInstance<ServiceMonitorStatus>> instancesOnThisHost;
+ Set<ServiceInstance<ServiceMonitorStatus>> instancesOnOtherHosts;
{
- final Map<Boolean, Set<ServiceInstance<ServiceMonitorStatus>>> serviceInstancesByLocality =
+ Map<Boolean, Set<ServiceInstance<ServiceMonitorStatus>>> serviceInstancesByLocality =
serviceCluster.serviceInstances().stream()
.collect(
Collectors.groupingBy(
@@ -80,7 +79,7 @@ public class HostedVespaPolicy implements Policy {
}
if (VespaModelUtil.isStorage(serviceCluster)) {
- final boolean thisHostHasSomeUpInstances = instancesOnThisHost.stream()
+ boolean thisHostHasSomeUpInstances = instancesOnThisHost.stream()
.map(ServiceInstance::serviceStatus)
.anyMatch(status -> status == ServiceMonitorStatus.UP);
if (thisHostHasSomeUpInstances) {
@@ -88,7 +87,7 @@ public class HostedVespaPolicy implements Policy {
}
}
- final boolean thisHostHasOnlyDownInstances = instancesOnThisHost.stream()
+ boolean thisHostHasOnlyDownInstances = instancesOnThisHost.stream()
.map(ServiceInstance::serviceStatus)
.allMatch(status -> status == ServiceMonitorStatus.DOWN);
if (thisHostHasOnlyDownInstances) {
@@ -96,7 +95,7 @@ public class HostedVespaPolicy implements Policy {
continue;
}
- final Set<ServiceInstance<ServiceMonitorStatus>> possiblyDownInstancesOnOtherHosts =
+ Set<ServiceInstance<ServiceMonitorStatus>> possiblyDownInstancesOnOtherHosts =
instancesOnOtherHosts.stream()
.filter(instance -> effectivelyDown(instance, hostStatusMap))
.collect(Collectors.toSet());
@@ -108,25 +107,25 @@ public class HostedVespaPolicy implements Policy {
}
// Now calculate what the service suspension percentage will be if we suspend this host.
- final int numServiceInstancesTotal = serviceCluster.serviceInstances().size();
- final int numInstancesThatWillBeSuspended = union(possiblyDownInstancesOnOtherHosts, instancesOnThisHost).size();
- final int percentThatWillBeSuspended = numInstancesThatWillBeSuspended * 100 / numServiceInstancesTotal;
- final int suspendPercentageAllowed = ServiceClusterSuspendPolicy.getSuspendPercentageAllowed(serviceCluster);
+ int numServiceInstancesTotal = serviceCluster.serviceInstances().size();
+ int numInstancesThatWillBeSuspended = union(possiblyDownInstancesOnOtherHosts, instancesOnThisHost).size();
+ int percentThatWillBeSuspended = numInstancesThatWillBeSuspended * 100 / numServiceInstancesTotal;
+ int suspendPercentageAllowed = ServiceClusterSuspendPolicy.getSuspendPercentageAllowed(serviceCluster);
if (percentThatWillBeSuspended > suspendPercentageAllowed) {
// It may seem like this may in some cases prevent upgrading, especially for small clusters (where the
// percentage of service instances affected by suspending a single host may easily exceed the allowed
// suspension percentage). Note that we always allow progress by allowing a single host to suspend.
// See previous section.
- final int currentSuspensionPercentage
+ int currentSuspensionPercentage
= possiblyDownInstancesOnOtherHosts.size() * 100 / numServiceInstancesTotal;
- final Set<HostName> otherHostsWithThisServiceCluster = instancesOnOtherHosts.stream()
+ Set<HostName> otherHostsWithThisServiceCluster = instancesOnOtherHosts.stream()
.map(ServiceInstance::hostName)
.collect(Collectors.toSet());
- final Set<HostName> hostsAllowedToBeDown = hostStatusMap.entrySet().stream()
+ Set<HostName> hostsAllowedToBeDown = hostStatusMap.entrySet().stream()
.filter(entry -> entry.getValue() == HostStatus.ALLOWED_TO_BE_DOWN)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
- final Set<HostName> otherHostsAllowedToBeDown
+ Set<HostName> otherHostsAllowedToBeDown
= intersection(otherHostsWithThisServiceCluster, hostsAllowedToBeDown);
throw new HostStateChangeDeniedException(
hostName,
@@ -155,23 +154,23 @@ public class HostedVespaPolicy implements Policy {
log.log(LogLevel.INFO, hostName + " is now allowed to be down (suspended)");
}
- private static <T> Set<T> union(final Set<T> setA, Set<T> setB) {
- final Set<T> union = new HashSet<>(setA);
+ private static <T> Set<T> union(Set<T> setA, Set<T> setB) {
+ Set<T> union = new HashSet<>(setA);
union.addAll(setB);
return union;
}
- private static <T> Set<T> intersection(final Set<T> setA, Set<T> setB) {
- final Set<T> intersection = new HashSet<>(setA);
+ private static <T> Set<T> intersection(Set<T> setA, Set<T> setB) {
+ Set<T> intersection = new HashSet<>(setA);
intersection.retainAll(setB);
return intersection;
}
@Override
public void releaseSuspensionGrant(
- final ApplicationInstance<ServiceMonitorStatus> applicationInstance,
- final HostName hostName,
- final MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException {
+ ApplicationInstance<ServiceMonitorStatus> applicationInstance,
+ HostName hostName,
+ MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException {
Set<ServiceCluster<ServiceMonitorStatus>> serviceClustersOnHost =
getServiceClustersUsingHost(applicationInstance.serviceClusters(), hostName);
@@ -183,21 +182,19 @@ public class HostedVespaPolicy implements Policy {
log.log(LogLevel.INFO, hostName + " is no longer allowed to be down (resumed)");
}
- private static boolean effectivelyDown(
- final ServiceInstance<ServiceMonitorStatus> serviceInstance,
- final Map<HostName, HostStatus> hostStatusMap) {
- final ServiceMonitorStatus instanceStatus = serviceInstance.serviceStatus();
- final HostStatus hostStatus = hostStatusMap.get(serviceInstance.hostName());
+ private static boolean effectivelyDown(ServiceInstance<ServiceMonitorStatus> serviceInstance,
+ Map<HostName, HostStatus> hostStatusMap) {
+ ServiceMonitorStatus instanceStatus = serviceInstance.serviceStatus();
+ HostStatus hostStatus = hostStatusMap.get(serviceInstance.hostName());
return hostStatus == HostStatus.ALLOWED_TO_BE_DOWN || instanceStatus == ServiceMonitorStatus.DOWN;
}
- private void setNodeStateInController(
- ApplicationInstance<?> application,
- HostName hostName,
- ClusterControllerState nodeState) throws HostStateChangeDeniedException {
+ private void setNodeStateInController(ApplicationInstance<?> application,
+ HostName hostName,
+ ClusterControllerState nodeState) throws HostStateChangeDeniedException {
ClusterId contentClusterId = VespaModelUtil.getContentClusterName(application, hostName);
Set<? extends ServiceInstance<?>> clusterControllers = VespaModelUtil.getClusterControllerInstances(application, contentClusterId);
- final ClusterControllerClient client = clusterControllerClientFactory.createClient(
+ ClusterControllerClient client = clusterControllerClientFactory.createClient(
clusterControllers,
contentClusterId.s());
int nodeIndex = VespaModelUtil.getStorageNodeIndex(application, hostName);
@@ -209,7 +206,7 @@ public class HostedVespaPolicy implements Policy {
", node index " + nodeIndex +
", node state " + nodeState);
- final ClusterControllerStateResponse response;
+ ClusterControllerStateResponse response;
try {
response = client.setNodeState(nodeIndex, nodeState);
} catch (IOException e) {
@@ -221,7 +218,7 @@ public class HostedVespaPolicy implements Policy {
e);
}
- if (!response.wasModified) {
+ if ( ! response.wasModified) {
throw new HostStateChangeDeniedException(
hostName,
SET_NODE_STATE_CONSTRAINT,
@@ -229,4 +226,5 @@ public class HostedVespaPolicy implements Policy {
"Failed to set state to " + nodeState + " in controller: " + response.reason);
}
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/Policy.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/Policy.java
index 53992436ea5..5b8627edcc9 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/Policy.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/Policy.java
@@ -10,6 +10,7 @@ import com.yahoo.vespa.service.monitor.ServiceMonitorStatus;
* @author oyving
*/
public interface Policy {
+
/**
* Decide whether to grant a request for temporarily suspending the services on a host.
*
@@ -29,4 +30,5 @@ public interface Policy {
ApplicationInstance<ServiceMonitorStatus> applicationInstance,
HostName hostName,
MutableStatusRegistry hostStatusService) throws HostStateChangeDeniedException;
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ServiceClusterSuspendPolicy.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ServiceClusterSuspendPolicy.java
index 7cb20cb8657..ba14b616d96 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ServiceClusterSuspendPolicy.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ServiceClusterSuspendPolicy.java
@@ -9,13 +9,14 @@ import com.yahoo.vespa.applicationmodel.ServiceCluster;
* @author bakksjo
*/
public final class ServiceClusterSuspendPolicy {
+
private static final int SUSPENSION_ALLOW_MINIMAL = 0;
private static final int SUSPENSION_ALLOW_TEN_PERCENT = 10;
private static final int SUSPENSION_ALLOW_ALL = 100;
private ServiceClusterSuspendPolicy() {} // Disallow instantiation.
- public static int getSuspendPercentageAllowed(final ServiceCluster<?> serviceCluster) {
+ public static int getSuspendPercentageAllowed(ServiceCluster<?> serviceCluster) {
if (VespaModelUtil.ADMIN_CLUSTER_ID.equals(serviceCluster.clusterId())) {
if (VespaModelUtil.SLOBROK_SERVICE_TYPE.equals(serviceCluster.serviceType())) {
return SUSPENSION_ALLOW_MINIMAL;
@@ -30,4 +31,5 @@ public final class ServiceClusterSuspendPolicy {
return SUSPENSION_ALLOW_TEN_PERCENT;
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionResource.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionResource.java
index 7006b6f6b85..6fc413bee9a 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionResource.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionResource.java
@@ -26,13 +26,13 @@ import java.util.stream.Collectors;
*/
@Path(ApplicationSuspensionApi.PATH_PREFIX)
public class ApplicationSuspensionResource implements ApplicationSuspensionApi {
+
private static final Logger log = Logger.getLogger(ApplicationSuspensionResource.class.getName());
private final OrchestratorImpl orchestrator;
@Inject
- public ApplicationSuspensionResource(
- @Component OrchestratorImpl orchestrator) {
+ public ApplicationSuspensionResource(@Component OrchestratorImpl orchestrator) {
this.orchestrator = orchestrator;
}
@@ -118,4 +118,5 @@ public class ApplicationSuspensionResource implements ApplicationSuspensionApi {
throw new BadRequestException(e);
}
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostResource.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostResource.java
index 80c625f0c40..b6dac92206c 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostResource.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostResource.java
@@ -36,8 +36,8 @@ public class HostResource implements HostApi {
}
@Override
- public GetHostResponse getHost(final String hostNameString) {
- final HostName hostName = new HostName(hostNameString);
+ public GetHostResponse getHost(String hostNameString) {
+ HostName hostName = new HostName(hostNameString);
try {
HostStatus status = orchestrator.getNodeStatus(hostName);
return new GetHostResponse(hostName.s(), status.name());
@@ -48,8 +48,8 @@ public class HostResource implements HostApi {
}
@Override
- public UpdateHostResponse suspend(final String hostNameString) {
- final HostName hostName = new HostName(hostNameString);
+ public UpdateHostResponse suspend(String hostNameString) {
+ HostName hostName = new HostName(hostNameString);
try {
orchestrator.suspend(hostName);
} catch (HostNameNotFoundException e) {
@@ -64,7 +64,7 @@ public class HostResource implements HostApi {
@Override
public UpdateHostResponse resume(final String hostNameString) {
- final HostName hostName = new HostName(hostNameString);
+ HostName hostName = new HostName(hostNameString);
try {
orchestrator.resume(hostName);
} catch (HostNameNotFoundException e) {
@@ -78,9 +78,9 @@ public class HostResource implements HostApi {
}
private static WebApplicationException webExceptionWithDenialReason(HostName hostName, HostStateChangeDeniedException e) {
- final HostStateChangeDenialReason hostStateChangeDenialReason = new HostStateChangeDenialReason(
+ HostStateChangeDenialReason hostStateChangeDenialReason = new HostStateChangeDenialReason(
e.getConstraintName(), e.getServiceType().s(), e.getMessage());
- final UpdateHostResponse response = new UpdateHostResponse(hostName.s(), hostStateChangeDenialReason);
+ UpdateHostResponse response = new UpdateHostResponse(hostName.s(), hostStateChangeDenialReason);
return new WebApplicationException(
hostStateChangeDenialReason.toString(),
e,
@@ -90,5 +90,6 @@ public class HostResource implements HostApi {
.build());
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostSuspensionResource.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostSuspensionResource.java
index d20d450c723..f61fae3b7c2 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostSuspensionResource.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/HostSuspensionResource.java
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
@Path(HostSuspensionApi.PATH_PREFIX)
public class HostSuspensionResource implements HostSuspensionApi {
+
private static final Logger log = Logger.getLogger(HostSuspensionResource.class.getName());
private final Orchestrator orchestrator;
@@ -34,13 +35,13 @@ public class HostSuspensionResource implements HostSuspensionApi {
@Override
public BatchOperationResult suspendAll(BatchHostSuspendRequest request) throws WebApplicationException {
- final String parentHostnameString = request.getParentHostname();
+ String parentHostnameString = request.getParentHostname();
if (parentHostnameString == null || parentHostnameString.isEmpty()) {
String message = "parentHostname missing or empty in request: " + request;
log.log(LogLevel.DEBUG, message);
throw createWebApplicationException(message, Response.Status.BAD_REQUEST);
}
- final List<String> hostnamesAsStrings = request.getHostnames();
+ List<String> hostnamesAsStrings = request.getHostnames();
if (hostnamesAsStrings == null) {
String message = "hostnames missing in request: " + request;
log.log(LogLevel.DEBUG, message);
@@ -76,4 +77,5 @@ public class HostSuspensionResource implements HostSuspensionApi {
.type(MediaType.APPLICATION_JSON_TYPE)
.build());
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceResource.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceResource.java
index 8b3862207b9..5765d2ee409 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceResource.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/resources/InstanceResource.java
@@ -41,9 +41,8 @@ public class InstanceResource {
private final InstanceLookupService instanceLookupService;
@Inject
- public InstanceResource(
- @Component final InstanceLookupService instanceLookupService,
- @Component final StatusService statusService) {
+ public InstanceResource(@Component InstanceLookupService instanceLookupService,
+ @Component StatusService statusService) {
this.instanceLookupService = instanceLookupService;
this.statusService = statusService;
}
@@ -58,24 +57,21 @@ public class InstanceResource {
@Path("/{instanceId}")
@Produces(MediaType.APPLICATION_JSON)
public InstanceStatusResponse getInstance(@PathParam("instanceId") String instanceIdString) {
- final ApplicationInstanceReference instanceId;
+ ApplicationInstanceReference instanceId;
try {
instanceId = parseAppInstanceReference(instanceIdString);
} catch (IllegalArgumentException e) {
throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).build());
}
- final ApplicationInstance<ServiceMonitorStatus> applicationInstance
+ ApplicationInstance<ServiceMonitorStatus> applicationInstance
= instanceLookupService.findInstanceById(instanceId)
.orElseThrow(() -> new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()));
- final Set<HostName> hostsUsedByApplicationInstance = getHostsUsedByApplicationInstance(applicationInstance);
- final Map<HostName, HostStatus> hostStatusMap = getHostStatusMap(
- hostsUsedByApplicationInstance,
- statusService.forApplicationInstance(instanceId));
- final Map<HostName, String> hostStatusStringMap = OrchestratorUtil.mapValues(
- hostStatusMap,
- HostStatus::name);
+ Set<HostName> hostsUsedByApplicationInstance = getHostsUsedByApplicationInstance(applicationInstance);
+ Map<HostName, HostStatus> hostStatusMap = getHostStatusMap(hostsUsedByApplicationInstance,
+ statusService.forApplicationInstance(instanceId));
+ Map<HostName, String> hostStatusStringMap = OrchestratorUtil.mapValues(hostStatusMap, HostStatus::name);
return InstanceStatusResponse.create(applicationInstance, hostStatusStringMap);
}
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/InMemoryStatusService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/InMemoryStatusService.java
index cbe5295799b..3430e7f16d5 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/InMemoryStatusService.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/InMemoryStatusService.java
@@ -22,19 +22,15 @@ public class InMemoryStatusService implements StatusService {
private final Set<ApplicationInstanceReference> applicationStatus = new HashSet<>();
private final LockService<ApplicationInstanceReference> instanceLockService = new LockService<>();
- private void setHostStatus(
- HostName hostName,
- HostStatus status) {
-
+ private void setHostStatus(HostName hostName, HostStatus status) {
hostServiceStatus.put(hostName, status);
}
@Override
- public ReadOnlyStatusRegistry forApplicationInstance(
- final ApplicationInstanceReference applicationInstanceReference) {
+ public ReadOnlyStatusRegistry forApplicationInstance(ApplicationInstanceReference applicationInstanceReference) {
return new ReadOnlyStatusRegistry() {
@Override
- public HostStatus getHostStatus(final HostName hostName) {
+ public HostStatus getHostStatus(HostName hostName) {
return hostServiceStatus.getOrDefault(hostName, HostStatus.NO_REMARKS);
}
@@ -47,9 +43,8 @@ public class InMemoryStatusService implements StatusService {
}
@Override
- public MutableStatusRegistry lockApplicationInstance_forCurrentThreadOnly(
- final ApplicationInstanceReference applicationInstanceReference) {
- final Lock lock = instanceLockService.get(applicationInstanceReference);
+ public MutableStatusRegistry lockApplicationInstance_forCurrentThreadOnly(ApplicationInstanceReference applicationInstanceReference) {
+ Lock lock = instanceLockService.get(applicationInstanceReference);
return new InMemoryMutableStatusRegistry(lock, applicationInstanceReference);
}
@@ -59,11 +54,11 @@ public class InMemoryStatusService implements StatusService {
}
private class InMemoryMutableStatusRegistry implements MutableStatusRegistry {
+
private final Lock lockHandle;
private final ApplicationInstanceReference ref;
- public InMemoryMutableStatusRegistry(final Lock lockHandle,
- final ApplicationInstanceReference ref) {
+ public InMemoryMutableStatusRegistry(Lock lockHandle, ApplicationInstanceReference ref) {
this.lockHandle = lockHandle;
this.ref = ref;
}
@@ -100,6 +95,7 @@ public class InMemoryStatusService implements StatusService {
}
private static class LockService<T> {
+
private final Map<T, Lock> locks;
public LockService() {
@@ -117,4 +113,5 @@ public class InMemoryStatusService implements StatusService {
}
}
}
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/MutableStatusRegistry.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/MutableStatusRegistry.java
index dc46a352fe7..08d155fa451 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/MutableStatusRegistry.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/MutableStatusRegistry.java
@@ -11,6 +11,7 @@ import com.yahoo.vespa.applicationmodel.HostName;
* @author bakksjo
*/
public interface MutableStatusRegistry extends ReadOnlyStatusRegistry, AutoCloseable {
+
/**
* Sets the state for the given host.
*/
@@ -28,4 +29,5 @@ public interface MutableStatusRegistry extends ReadOnlyStatusRegistry, AutoClose
@Override
@NoThrow
void close();
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ReadOnlyStatusRegistry.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ReadOnlyStatusRegistry.java
index c8f9bbf208b..6e939e7eec1 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ReadOnlyStatusRegistry.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ReadOnlyStatusRegistry.java
@@ -11,6 +11,7 @@ import com.yahoo.vespa.applicationmodel.HostName;
* @author bakksjo
*/
public interface ReadOnlyStatusRegistry {
+
/**
* Gets the current state for the given host.
*/
@@ -20,4 +21,5 @@ public interface ReadOnlyStatusRegistry {
* Gets the current status for the application instance.
*/
ApplicationInstanceStatus getApplicationInstanceStatus();
+
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java
index d9df5800ee8..de24f5fe296 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZookeeperStatusService.java
@@ -33,6 +33,7 @@ import java.util.logging.Logger;
* @author tonytv
*/
public class ZookeeperStatusService implements StatusService {
+
private static final Logger log = Logger.getLogger(ZookeeperStatusService.class.getName());
//For debug purposes only: Used to check that operations depending on a lock is done from a single thread,
@@ -59,11 +60,10 @@ public class ZookeeperStatusService implements StatusService {
}
@Override
- public ReadOnlyStatusRegistry forApplicationInstance(
- final ApplicationInstanceReference applicationInstanceReference) {
+ public ReadOnlyStatusRegistry forApplicationInstance(ApplicationInstanceReference applicationInstanceReference) {
return new ReadOnlyStatusRegistry() {
@Override
- public HostStatus getHostStatus(final HostName hostName) {
+ public HostStatus getHostStatus(HostName hostName) {
return getInternalHostStatus(applicationInstanceReference, hostName);
}
@@ -85,8 +85,7 @@ public class ZookeeperStatusService implements StatusService {
* (i.e. the request is for another applicationInstanceReference)
*/
@Override
- public MutableStatusRegistry lockApplicationInstance_forCurrentThreadOnly(
- final ApplicationInstanceReference applicationInstanceReference) {
+ public MutableStatusRegistry lockApplicationInstance_forCurrentThreadOnly(ApplicationInstanceReference applicationInstanceReference) {
return lockApplicationInstance_forCurrentThreadOnly(applicationInstanceReference, 10, TimeUnit.SECONDS);
}
@@ -112,19 +111,16 @@ public class ZookeeperStatusService implements StatusService {
}
}
- MutableStatusRegistry lockApplicationInstance_forCurrentThreadOnly(
- ApplicationInstanceReference applicationInstanceReference,
- long timeout,
- TimeUnit timeoutTimeUnit) {
-
- final Thread currentThread = Thread.currentThread();
+ MutableStatusRegistry lockApplicationInstance_forCurrentThreadOnly(ApplicationInstanceReference applicationInstanceReference,
+ long timeout,
+ TimeUnit timeoutTimeUnit) {
+ Thread currentThread = Thread.currentThread();
//Due to limitations in SessionFailRetryLoop.
- assertThreadDoesNotHoldLock(currentThread,
- "Can't lock " + applicationInstanceReference);
+ assertThreadDoesNotHoldLock(currentThread,"Can't lock " + applicationInstanceReference);
try {
- SessionFailRetryLoop sessionFailRetryLoop =
+ SessionFailRetryLoop sessionFailRetryLoop =
curatorFramework.getZookeeperClient().newSessionFailRetryLoop(Mode.FAIL);
sessionFailRetryLoop.start();
try {
@@ -167,10 +163,9 @@ public class ZookeeperStatusService implements StatusService {
return mutex;
}
- private void setHostStatus(
- ApplicationInstanceReference applicationInstanceReference,
- HostName hostName,
- HostStatus status) {
+ private void setHostStatus(ApplicationInstanceReference applicationInstanceReference,
+ HostName hostName,
+ HostStatus status) {
assertThreadHoldsLock(applicationInstanceReference);
String path = hostAllowedDownPath(applicationInstanceReference, hostName);
@@ -178,12 +173,11 @@ public class ZookeeperStatusService implements StatusService {
try {
switch (status) {
case NO_REMARKS:
- deleteNode_ignoreNoNodeException(path,
- "Host already has state NO_REMARKS, path = " + path);
+ deleteNode_ignoreNoNodeException(path,"Host already has state NO_REMARKS, path = " + path);
break;
case ALLOWED_TO_BE_DOWN:
createNode_ignoreNodeExistsException(path,
- "Host already has state ALLOWED_TO_BE_DOWN, path = " + path);
+ "Host already has state ALLOWED_TO_BE_DOWN, path = " + path);
}
} catch (Exception e) {
//TODO: IOException with explanation