Skip to content

Commit

Permalink
fix(boot2): camel to kebab for fast properties (#2920)
Browse files Browse the repository at this point in the history
* fix(boot2): camel to kebab for fast properties
* fix(boot2): kebab the force cache refresh property
  • Loading branch information
emjburns committed May 16, 2019
1 parent 99a42c4 commit bb4efbc
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ConditionConfigurationProperties(DynamicConfigService configService) {
}

public boolean isEnabled() {
return configService.getConfig(Boolean.class, "tasks.evaluateCondition", enabled);
return configService.getConfig(Boolean.class, "tasks.evaluate-condition", enabled);
}

public void setEnabled(boolean enabled) {
Expand All @@ -48,7 +48,7 @@ public void setEnabled(boolean enabled) {

public Long getBackoffWaitMs() {
return configService.getConfig(
Long.class, "tasks.evaluateCondition.backoffWaitMs", backoffWaitMs);
Long.class, "tasks.evaluate-condition.backoff-wait-ms", backoffWaitMs);
}

public void setBackoffWaitMs(Long backoffWaitMs) {
Expand All @@ -57,20 +57,20 @@ public void setBackoffWaitMs(Long backoffWaitMs) {

public long getWaitTimeoutMs() {
return configService.getConfig(
Long.class, "tasks.evaluateCondition.waitTimeoutMs", waitTimeoutMs);
Long.class, "tasks.evaluate-condition.wait-timeout-ms", waitTimeoutMs);
}

public void setWaitTimeoutMs(long waitTimeoutMs) {
this.waitTimeoutMs = waitTimeoutMs;
}

public List<String> getClusters() {
return configService.getConfig(List.class, "tasks.evaluateCondition.clusters", clusters);
return configService.getConfig(List.class, "tasks.evaluate-condition.clusters", clusters);
}

public List<String> getActiveConditions() {
return configService.getConfig(
List.class, "tasks.evaluateCondition.activeConditions", activeConditions);
List.class, "tasks.evaluate-condition.active-conditions", activeConditions);
}

public void setClusters(List<String> clusters) {
Expand All @@ -82,6 +82,6 @@ public void setActiveConditions(List<String> activeConditions) {
}

public boolean isSkipWait() {
return configService.getConfig(Boolean.class, "tasks.evaluateCondition.skipWait", false);
return configService.getConfig(Boolean.class, "tasks.evaluate-condition.skip-wait", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.netflix.spinnaker.orca.clouddriver.tasks.cluster

import java.util.function.Function
import com.netflix.spinnaker.orca.ExecutionStatus
import com.netflix.spinnaker.orca.TaskResult
import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@Component
public class TrafficGuard {
private static final String MIN_CAPACITY_RATIO = "trafficGuards.minCapacityRatio";
private static final String MIN_CAPACITY_RATIO = "traffic-guards.min-capacity-ratio";
private final Logger log = LoggerFactory.getLogger(getClass());

private final OortHelper oortHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public LockingConfigurationProperties(DynamicConfigService dynamicConfigService)
}

public boolean isLearningMode() {
return dynamicConfigService.getConfig(Boolean.class, "locking.learningMode", learningMode);
return dynamicConfigService.getConfig(Boolean.class, "locking.learning-mode", learningMode);
}

public void setLearningMode(boolean learningMode) {
Expand All @@ -51,7 +51,7 @@ public void setEnabled(boolean enabled) {
}

public int getTtlSeconds() {
return dynamicConfigService.getConfig(Integer.class, "locking.ttlSeconds", ttlSeconds);
return dynamicConfigService.getConfig(Integer.class, "locking.ttl-seconds", ttlSeconds);
}

public void setTtlSeconds(int ttlSeconds) {
Expand All @@ -60,7 +60,7 @@ public void setTtlSeconds(int ttlSeconds) {

public int getBackoffBufferSeconds() {
return dynamicConfigService.getConfig(
Integer.class, "locking.backoffBufferSeconds", backoffBufferSeconds);
Integer.class, "locking.backoff-buffer-seconds", backoffBufferSeconds);
}

public void setBackoffBufferSeconds(int backoffBufferSeconds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;

import com.google.common.base.CaseFormat;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.orca.pipeline.TaskNode.TaskGraph;
import com.netflix.spinnaker.orca.pipeline.graph.StageGraphBuilder;
Expand Down Expand Up @@ -165,8 +166,10 @@ default boolean isForceCacheRefreshEnabled(DynamicConfigService dynamicConfigSer
try {
return dynamicConfigService.isEnabled(
String.format(
"stages.%s.forceCacheRefresh",
Character.toLowerCase(className.charAt(0)) + className.substring(1)),
"stages.%s.force-cache-refresh",
CaseFormat.LOWER_CAMEL.to(
CaseFormat.LOWER_HYPHEN,
Character.toLowerCase(className.charAt(0)) + className.substring(1))),
true);
} catch (Exception e) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class StageDefinitionBuilderSpec extends Specification {
def isForceCacheRefreshEnabled = stageDefinitionBuilder.isForceCacheRefreshEnabled(dynamicConfigService)

then:
1 * dynamicConfigService.isEnabled("stages.myStageDefinitionBuilder.forceCacheRefresh", true) >> {
1 * dynamicConfigService.isEnabled("stages.my-stage-definition-builder.force-cache-refresh", true) >> {
return response()
}
0 * _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ExecutionBufferActuator(
withActionDecision(execution) {
when (it.action) {
BUFFER -> {
if (configService.isEnabled("qos.learningMode", true)) {
if (configService.isEnabled("qos.learning-mode", true)) {
log.debug("Learning mode: Would have buffered execution {} (using $supplierName), reason: ${it.reason}", value("executionId", execution.id))
registry.counter(bufferedId.withTag("learning", "true")).increment()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NaiveBufferPolicy(
) : BufferPolicy {

override fun apply(execution: Execution): BufferResult {
if (!configService.isEnabled("qos.bufferPolicy.naive", true)) {
if (!configService.isEnabled("qos.buffer-policy.naive", true)) {
return BufferResult(ENQUEUE, false, "Naive policy is disabled")
}
return BufferResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class ActiveExecutionsBufferStateSupplier(
override fun get() = state

override fun enabled() =
configService.getConfig(String::class.java, "qos.bufferingState.supplier", "") == "activeExecutions"
configService.getConfig(String::class.java, "qos.buffering-state.supplier", "") == "activeExecutions"

private fun getThreshold() =
configService.getConfig(Int::class.java, "qos.bufferingState.activeExecutions.threshold", 100)
configService.getConfig(Int::class.java, "qos.buffering-state.active-executions.threshold", 100)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class KillSwitchBufferStateSupplier(
) : BufferStateSupplier {

override fun enabled() =
configService.getConfig(String::class.java, "qos.bufferingState.supplier", "") == "killSwitch"
configService.getConfig(String::class.java, "qos.buffering-state.supplier", "") == "killSwitch"

override fun get() =
when (configService.isEnabled("qos.bufferingState.killSwitch", false)) {
when (configService.isEnabled("qos.buffering-state.kill-switch", false)) {
true -> ACTIVE
false -> INACTIVE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class NaivePromotionPolicy(
) : PromotionPolicy {

override fun apply(candidates: List<Execution>): PromotionResult {
if (!configService.isEnabled("qos.promotionPolicy.naive", true)) {
if (!configService.isEnabled("qos.promotion-policy.naive", true)) {
return PromotionResult(candidates, false, "Naive policy is disabled")
}

val maxPromoteSize = configService.getConfig(Int::class.java, "qos.promotionPolicy.naive.size", 1)
val maxPromoteSize = configService.getConfig(Int::class.java, "qos.promotion-policy.naive.size", 1)
val promoteSize = if (maxPromoteSize > candidates.size) candidates.size else maxPromoteSize

return PromotionResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ExecutionBufferActuatorTest : SubjectSpek<ExecutionBufferActuator>({
describe("buffering executions") {
beforeGroup {
whenever(configService.isEnabled(eq("qos"), any())) doReturn true
whenever(configService.isEnabled(eq("qos.learningMode"), any())) doReturn false
whenever(configService.isEnabled(eq("qos.learning-mode"), any())) doReturn false
}
afterGroup(::resetMocks)

Expand Down

0 comments on commit bb4efbc

Please sign in to comment.