diff options
author | HÃ¥kon Hallingstad <hakon@oath.com> | 2018-06-25 12:27:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 12:27:11 +0200 |
commit | 948c3a15a1ceb5a7d58ab7ff3d1e33ea0996f2da (patch) | |
tree | 98636af2bad8b6fbf901d8e2c1d51b02e690f3a7 /orchestrator | |
parent | ab61e5ea77c483c0fe4fb6a3f266bd47f590988a (diff) | |
parent | 8e0db9bca4cdf4dec43b3d46fcf1a8b1d33e99ec (diff) |
Merge pull request #6266 from vespa-engine/hakonhall/set-node-state-timeout-in-cc
set-node-state timeout in CC
Diffstat (limited to 'orchestrator')
4 files changed, 8 insertions, 12 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorContext.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorContext.java index 880eab0c755..e795e16813f 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorContext.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorContext.java @@ -6,7 +6,6 @@ import com.yahoo.time.TimeBudget; import java.time.Clock; import java.time.Duration; -import java.util.Optional; /** * Context for the Orchestrator, e.g. timeout management. @@ -24,14 +23,14 @@ public class OrchestratorContext { /** Get the original timeout in seconds. */ public long getOriginalTimeoutInSeconds() { - return timeBudget.originalTimeout().getSeconds(); + return timeBudget.originalTimeout().get().getSeconds(); } /** * Get number of seconds until the deadline, or empty if there's no deadline, or throw * an {@link UncheckedTimeoutException} if timed out. */ - public Optional<Float> getSuboperationTimeoutInSeconds() { - return Optional.of((float) (timeBudget.timeLeftOrThrow().toMillis() / 1000.0)); + public float getSuboperationTimeoutInSeconds() { + return (float) (timeBudget.timeLeftOrThrow().get().toMillis() / 1000.0); } } 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 7d7a9b36ff9..ba469c1617e 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 @@ -40,7 +40,7 @@ public class ClusterControllerClientImpl implements ClusterControllerClient{ return clusterControllerApi.apply(api -> api.setNodeState( clusterName, storageNodeIndex, - context.getSuboperationTimeoutInSeconds().orElse(null), + context.getSuboperationTimeoutInSeconds(), stateRequest) ); } catch (IOException e) { @@ -69,7 +69,7 @@ public class ClusterControllerClientImpl implements ClusterControllerClient{ try { return clusterControllerApi.apply(api -> api.setClusterState( clusterName, - context.getSuboperationTimeoutInSeconds().orElse(null), + context.getSuboperationTimeoutInSeconds(), stateRequest)); } catch (IOException e) { final String message = String.format( diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTest.java index b3f80b5129f..c1dfc5d38f2 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTest.java @@ -6,8 +6,6 @@ import com.yahoo.vespa.jaxrs.client.LocalPassThroughJaxRsStrategy; import com.yahoo.vespa.orchestrator.OrchestratorContext; import org.junit.Test; -import java.util.Optional; - import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -29,7 +27,7 @@ public class ClusterControllerClientTest { final ClusterControllerNodeState wantedState = ClusterControllerNodeState.MAINTENANCE; OrchestratorContext context = mock(OrchestratorContext.class); - when(context.getSuboperationTimeoutInSeconds()).thenReturn(Optional.of(1.0f)); + when(context.getSuboperationTimeoutInSeconds()).thenReturn(1.0f); clusterControllerClient.setNodeState(context, STORAGE_NODE_INDEX, wantedState); final ClusterControllerStateRequest expectedNodeStateRequest = new ClusterControllerStateRequest( diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactoryTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactoryTest.java index c3dbe5c8a92..87f07688c34 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactoryTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/SingleInstanceClusterControllerClientFactoryTest.java @@ -10,7 +10,6 @@ import org.junit.Test; import java.util.Arrays; import java.util.List; -import java.util.Optional; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.equalTo; @@ -67,7 +66,7 @@ public class SingleInstanceClusterControllerClientFactoryTest { public void testCreateClientWithSingleClusterControllerInstance() throws Exception { final List<HostName> clusterControllers = Arrays.asList(HOST_NAME_1); - when(context.getSuboperationTimeoutInSeconds()).thenReturn(Optional.of(1.0f)); + when(context.getSuboperationTimeoutInSeconds()).thenReturn(1.0f); clientFactory.createClient(clusterControllers, "clusterName") .setNodeState(context, 0, ClusterControllerNodeState.MAINTENANCE); @@ -95,7 +94,7 @@ public class SingleInstanceClusterControllerClientFactoryTest { public void testCreateClientWithThreeClusterControllerInstances() throws Exception { final List<HostName> clusterControllers = Arrays.asList(HOST_NAME_1, HOST_NAME_2, HOST_NAME_3); - when(context.getSuboperationTimeoutInSeconds()).thenReturn(Optional.of(1.0f)); + when(context.getSuboperationTimeoutInSeconds()).thenReturn(1.0f); clientFactory.createClient(clusterControllers, "clusterName") .setNodeState(context, 0, ClusterControllerNodeState.MAINTENANCE); |