From fb21ab2649cd20e2361926404e1843c47c15d4fd Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Thu, 3 Dec 2020 14:03:25 +0100 Subject: Move non-permanent feature flags to ModelContext.FeatureFlags --- .../config/server/deploy/ModelContextImpl.java | 147 ++++++++++++--------- .../vespa/config/server/ModelContextImplTest.java | 1 + 2 files changed, 89 insertions(+), 59 deletions(-) (limited to 'configserver/src') diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index eda962af5ac..9f3ae86b2cf 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -149,12 +149,57 @@ public class ModelContextImpl implements ModelContext { public static class FeatureFlags implements ModelContext.FeatureFlags { private final boolean enableAutomaticReindexing; + private final double defaultTermwiseLimit; + private final boolean useThreePhaseUpdates; + private final boolean useDirectStorageApiRpc; + private final boolean useFastValueTensorImplementation; + private final String feedSequencer; + private final String responseSequencer; + private final int numResponseThreads; + private final boolean skipCommunicationManagerThread; + private final boolean skipMbusRequestThread; + private final boolean skipMbusReplyThread; + private final boolean useAccessControlTlsHandshakeClientAuth; + private final boolean useAsyncMessageHandlingOnSchedule; + private final int contentNodeBucketDBStripeBits; + private final int mergeChunkSize; + private final double feedConcurrency; public FeatureFlags(FlagSource source, ApplicationId appId) { this.enableAutomaticReindexing = flagValue(source, appId, Flags.ENABLE_AUTOMATIC_REINDEXING); + defaultTermwiseLimit = flagValue(source, appId, Flags.DEFAULT_TERM_WISE_LIMIT); + useThreePhaseUpdates = flagValue(source, appId, Flags.USE_THREE_PHASE_UPDATES); + useDirectStorageApiRpc = flagValue(source, appId, Flags.USE_DIRECT_STORAGE_API_RPC); + useFastValueTensorImplementation = flagValue(source, appId, Flags.USE_FAST_VALUE_TENSOR_IMPLEMENTATION); + feedSequencer = flagValue(source, appId, Flags.FEED_SEQUENCER_TYPE); + responseSequencer = flagValue(source, appId, Flags.RESPONSE_SEQUENCER_TYPE); + numResponseThreads = flagValue(source, appId, Flags.RESPONSE_NUM_THREADS); + skipCommunicationManagerThread = flagValue(source, appId, Flags.SKIP_COMMUNICATIONMANAGER_THREAD); + skipMbusRequestThread = flagValue(source, appId, Flags.SKIP_MBUS_REQUEST_THREAD); + skipMbusReplyThread = flagValue(source, appId, Flags.SKIP_MBUS_REPLY_THREAD); + this.useAccessControlTlsHandshakeClientAuth = flagValue(source, appId, Flags.USE_ACCESS_CONTROL_CLIENT_AUTHENTICATION); + useAsyncMessageHandlingOnSchedule = flagValue(source, appId, Flags.USE_ASYNC_MESSAGE_HANDLING_ON_SCHEDULE); + contentNodeBucketDBStripeBits = flagValue(source, appId, Flags.CONTENT_NODE_BUCKET_DB_STRIPE_BITS); + mergeChunkSize = flagValue(source, appId, Flags.MERGE_CHUNK_SIZE); + feedConcurrency = flagValue(source, appId, Flags.FEED_CONCURRENCY); } @Override public boolean enableAutomaticReindexing() { return enableAutomaticReindexing; } + @Override public double defaultTermwiseLimit() { return defaultTermwiseLimit; } + @Override public boolean useThreePhaseUpdates() { return useThreePhaseUpdates; } + @Override public boolean useDirectStorageApiRpc() { return useDirectStorageApiRpc; } + @Override public boolean useFastValueTensorImplementation() { return useFastValueTensorImplementation; } + @Override public String feedSequencerType() { return feedSequencer; } + @Override public String responseSequencerType() { return responseSequencer; } + @Override public int defaultNumResponseThreads() { return numResponseThreads; } + @Override public boolean skipCommunicationManagerThread() { return skipCommunicationManagerThread; } + @Override public boolean skipMbusRequestThread() { return skipMbusRequestThread; } + @Override public boolean skipMbusReplyThread() { return skipMbusReplyThread; } + @Override public boolean useAccessControlTlsHandshakeClientAuth() { return useAccessControlTlsHandshakeClientAuth; } + @Override public boolean useAsyncMessageHandlingOnSchedule() { return useAsyncMessageHandlingOnSchedule; } + @Override public int contentNodeBucketDBStripeBits() { return contentNodeBucketDBStripeBits; } + @Override public int mergeChunkSize() { return mergeChunkSize; } + @Override public double feedConcurrency() { return feedConcurrency; } private static V flagValue(FlagSource source, ApplicationId appId, UnboundFlag flag) { return flag.bindTo(source) @@ -164,6 +209,7 @@ public class ModelContextImpl implements ModelContext { } + @SuppressWarnings("deprecation") // for old feature flag methods in ModelContext.Properties public static class Properties implements ModelContext.Properties { private final ModelContext.FeatureFlags featureFlags; @@ -178,21 +224,24 @@ public class ModelContextImpl implements ModelContext { private final Set endpoints; private final boolean isBootstrap; private final boolean isFirstTimeDeployment; + private final Optional endpointCertificateSecrets; + private final Optional athenzDomain; + private final Optional applicationRoles; + private final Quota quota; + + private final String jvmGCOPtions; + + // Old non-permanent feature flags. Use ModelContext.FeatureFlag instead + private final double defaultTermwiseLimit; private final boolean useThreePhaseUpdates; private final boolean useDirectStorageApiRpc; private final boolean useFastValueTensorImplementation; - private final Optional endpointCertificateSecrets; - private final double defaultTermwiseLimit; - private final String jvmGCOPtions; private final String feedSequencer; private final String responseSequencer; private final int numResponseThreads; private final boolean skipCommunicationManagerThread; private final boolean skipMbusRequestThread; private final boolean skipMbusReplyThread; - private final Optional athenzDomain; - private final Optional applicationRoles; - private final Quota quota; private final boolean useAccessControlTlsHandshakeClientAuth; private final boolean useAsyncMessageHandlingOnSchedule; private final int contentNodeBucketDBStripeBits; @@ -223,43 +272,28 @@ public class ModelContextImpl implements ModelContext { this.isBootstrap = isBootstrap; this.isFirstTimeDeployment = isFirstTimeDeployment; this.endpointCertificateSecrets = endpointCertificateSecrets; - defaultTermwiseLimit = Flags.DEFAULT_TERM_WISE_LIMIT.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - useThreePhaseUpdates = Flags.USE_THREE_PHASE_UPDATES.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - useDirectStorageApiRpc = Flags.USE_DIRECT_STORAGE_API_RPC.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - useFastValueTensorImplementation = Flags.USE_FAST_VALUE_TENSOR_IMPLEMENTATION.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - jvmGCOPtions = PermanentFlags.JVM_GC_OPTIONS.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - feedSequencer = Flags.FEED_SEQUENCER_TYPE.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - responseSequencer = Flags.RESPONSE_SEQUENCER_TYPE.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - numResponseThreads = Flags.RESPONSE_NUM_THREADS.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - skipCommunicationManagerThread = Flags.SKIP_COMMUNICATIONMANAGER_THREAD.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - skipMbusRequestThread = Flags.SKIP_MBUS_REQUEST_THREAD.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - skipMbusReplyThread = Flags.SKIP_MBUS_REPLY_THREAD.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); this.athenzDomain = athenzDomain; this.applicationRoles = applicationRoles; this.quota = maybeQuota.orElseGet(Quota::unlimited); - this.useAccessControlTlsHandshakeClientAuth = - Flags.USE_ACCESS_CONTROL_CLIENT_AUTHENTICATION.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()) - .value(); - useAsyncMessageHandlingOnSchedule = Flags.USE_ASYNC_MESSAGE_HANDLING_ON_SCHEDULE.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - contentNodeBucketDBStripeBits = Flags.CONTENT_NODE_BUCKET_DB_STRIPE_BITS.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - mergeChunkSize = Flags.MERGE_CHUNK_SIZE.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); - feedConcurrency = Flags.FEED_CONCURRENCY.bindTo(flagSource) - .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); + + jvmGCOPtions = flagValue(flagSource, applicationId, PermanentFlags.JVM_GC_OPTIONS); + + // Old non-permanent feature flags. Use ModelContext.FeatureFlag instead + defaultTermwiseLimit = flagValue(flagSource, applicationId, Flags.DEFAULT_TERM_WISE_LIMIT); + useThreePhaseUpdates = flagValue(flagSource, applicationId, Flags.USE_THREE_PHASE_UPDATES); + useDirectStorageApiRpc = flagValue(flagSource, applicationId, Flags.USE_DIRECT_STORAGE_API_RPC); + useFastValueTensorImplementation = flagValue(flagSource, applicationId, Flags.USE_FAST_VALUE_TENSOR_IMPLEMENTATION); + feedSequencer = flagValue(flagSource, applicationId, Flags.FEED_SEQUENCER_TYPE); + responseSequencer = flagValue(flagSource, applicationId, Flags.RESPONSE_SEQUENCER_TYPE); + numResponseThreads = flagValue(flagSource, applicationId, Flags.RESPONSE_NUM_THREADS); + skipCommunicationManagerThread = flagValue(flagSource, applicationId, Flags.SKIP_COMMUNICATIONMANAGER_THREAD); + skipMbusRequestThread = flagValue(flagSource, applicationId, Flags.SKIP_MBUS_REQUEST_THREAD); + skipMbusReplyThread = flagValue(flagSource, applicationId, Flags.SKIP_MBUS_REPLY_THREAD); + this.useAccessControlTlsHandshakeClientAuth = flagValue(flagSource, applicationId, Flags.USE_ACCESS_CONTROL_CLIENT_AUTHENTICATION); + useAsyncMessageHandlingOnSchedule = flagValue(flagSource, applicationId, Flags.USE_ASYNC_MESSAGE_HANDLING_ON_SCHEDULE); + contentNodeBucketDBStripeBits = flagValue(flagSource, applicationId, Flags.CONTENT_NODE_BUCKET_DB_STRIPE_BITS); + mergeChunkSize = flagValue(flagSource, applicationId, Flags.MERGE_CHUNK_SIZE); + feedConcurrency = flagValue(flagSource, applicationId, Flags.FEED_CONCURRENCY); } @Override public ModelContext.FeatureFlags featureFlags() { return featureFlags; } @@ -304,24 +338,6 @@ public class ModelContextImpl implements ModelContext { @Override public Optional endpointCertificateSecrets() { return endpointCertificateSecrets; } - @Override - public double defaultTermwiseLimit() { return defaultTermwiseLimit; } - - @Override - public boolean useThreePhaseUpdates() { - return useThreePhaseUpdates; - } - - @Override - public boolean useDirectStorageApiRpc() { - return useDirectStorageApiRpc; - } - - @Override - public boolean useFastValueTensorImplementation() { - return useFastValueTensorImplementation; - } - @Override public Optional athenzDomain() { return athenzDomain; } @@ -330,19 +346,32 @@ public class ModelContextImpl implements ModelContext { return applicationRoles; } + @Override public Quota quota() { return quota; } + @Override public String jvmGCOptions() { return jvmGCOPtions; } + + // Old non-permanent feature flags. Use ModelContext.FeatureFlag instead + @Override public double defaultTermwiseLimit() { return defaultTermwiseLimit; } + @Override public boolean useThreePhaseUpdates() { return useThreePhaseUpdates; } + @Override public boolean useDirectStorageApiRpc() { return useDirectStorageApiRpc; } + @Override public boolean useFastValueTensorImplementation() { return useFastValueTensorImplementation; } @Override public String feedSequencerType() { return feedSequencer; } @Override public String responseSequencerType() { return responseSequencer; } @Override public int defaultNumResponseThreads() { return numResponseThreads; } @Override public boolean skipCommunicationManagerThread() { return skipCommunicationManagerThread; } @Override public boolean skipMbusRequestThread() { return skipMbusRequestThread; } @Override public boolean skipMbusReplyThread() { return skipMbusReplyThread; } - @Override public Quota quota() { return quota; } @Override public boolean useAccessControlTlsHandshakeClientAuth() { return useAccessControlTlsHandshakeClientAuth; } @Override public boolean useAsyncMessageHandlingOnSchedule() { return useAsyncMessageHandlingOnSchedule; } @Override public int contentNodeBucketDBStripeBits() { return contentNodeBucketDBStripeBits; } @Override public int mergeChunkSize() { return mergeChunkSize; } @Override public double feedConcurrency() { return feedConcurrency; } + + private static V flagValue(FlagSource source, ApplicationId appId, UnboundFlag flag) { + return flag.bindTo(source) + .with(FetchVector.Dimension.APPLICATION_ID, appId.serializedForm()) + .boxedValue(); + } } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java index 6694ac8c694..47150f0d5a0 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ModelContextImplTest.java @@ -31,6 +31,7 @@ import static org.junit.Assert.assertTrue; /** * @author Ulf Lilleengen */ +@SuppressWarnings("deprecation") public class ModelContextImplTest { @Test -- cgit v1.2.3