12
12
import org .opensearch .common .settings .Setting .Property ;
13
13
import org .opensearch .common .settings .Settings ;
14
14
15
+ import java .util .List ;
16
+
15
17
/**
16
18
* Utility class to manage feature flags. Feature flags are system properties that must be set on the JVM.
17
- * These are used to gate the visibility/availability of incomplete features. Fore more information, see
19
+ * These are used to gate the visibility/availability of incomplete features. For more information, see
18
20
* https://featureflags.io/feature-flag-introduction/
19
21
*
20
22
* @opensearch.internal
@@ -65,19 +67,69 @@ public class FeatureFlags {
65
67
*/
66
68
public static final String PLUGGABLE_CACHE = "opensearch.experimental.feature.pluggable.caching.enabled" ;
67
69
70
+ public static final Setting <Boolean > REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING = Setting .boolSetting (
71
+ REMOTE_STORE_MIGRATION_EXPERIMENTAL ,
72
+ false ,
73
+ Property .NodeScope
74
+ );
75
+
76
+ public static final Setting <Boolean > EXTENSIONS_SETTING = Setting .boolSetting (EXTENSIONS , false , Property .NodeScope );
77
+
78
+ public static final Setting <Boolean > IDENTITY_SETTING = Setting .boolSetting (IDENTITY , false , Property .NodeScope );
79
+
80
+ public static final Setting <Boolean > TELEMETRY_SETTING = Setting .boolSetting (TELEMETRY , false , Property .NodeScope );
81
+
82
+ public static final Setting <Boolean > DATETIME_FORMATTER_CACHING_SETTING = Setting .boolSetting (
83
+ DATETIME_FORMATTER_CACHING ,
84
+ true ,
85
+ Property .NodeScope
86
+ );
87
+
88
+ public static final Setting <Boolean > WRITEABLE_REMOTE_INDEX_SETTING = Setting .boolSetting (
89
+ WRITEABLE_REMOTE_INDEX ,
90
+ false ,
91
+ Property .NodeScope
92
+ );
93
+
94
+ public static final Setting <Boolean > PLUGGABLE_CACHE_SETTING = Setting .boolSetting (PLUGGABLE_CACHE , false , Property .NodeScope );
95
+
96
+ private static final List <Setting <Boolean >> ALL_FEATURE_FLAG_SETTINGS = List .of (
97
+ REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING ,
98
+ EXTENSIONS_SETTING ,
99
+ IDENTITY_SETTING ,
100
+ TELEMETRY_SETTING ,
101
+ DATETIME_FORMATTER_CACHING_SETTING ,
102
+ WRITEABLE_REMOTE_INDEX_SETTING ,
103
+ PLUGGABLE_CACHE_SETTING
104
+ );
68
105
/**
69
106
* Should store the settings from opensearch.yml.
70
107
*/
71
108
private static Settings settings ;
72
109
110
+ static {
111
+ Settings .Builder settingsBuilder = Settings .builder ();
112
+ for (Setting <Boolean > ffSetting : ALL_FEATURE_FLAG_SETTINGS ) {
113
+ settingsBuilder = settingsBuilder .put (ffSetting .getKey (), ffSetting .getDefault (Settings .EMPTY ));
114
+ }
115
+ settings = settingsBuilder .build ();
116
+ }
117
+
73
118
/**
74
119
* This method is responsible to map settings from opensearch.yml to local stored
75
120
* settings value. That is used for the existing isEnabled method.
76
121
*
77
122
* @param openSearchSettings The settings stored in opensearch.yml.
78
123
*/
79
124
public static void initializeFeatureFlags (Settings openSearchSettings ) {
80
- settings = openSearchSettings ;
125
+ Settings .Builder settingsBuilder = Settings .builder ();
126
+ for (Setting <Boolean > ffSetting : ALL_FEATURE_FLAG_SETTINGS ) {
127
+ settingsBuilder = settingsBuilder .put (
128
+ ffSetting .getKey (),
129
+ openSearchSettings .getAsBoolean (ffSetting .getKey (), ffSetting .getDefault (openSearchSettings ))
130
+ );
131
+ }
132
+ settings = settingsBuilder .build ();
81
133
}
82
134
83
135
/**
@@ -103,30 +155,4 @@ public static boolean isEnabled(Setting<Boolean> featureFlag) {
103
155
return featureFlag .getDefault (Settings .EMPTY );
104
156
}
105
157
}
106
-
107
- public static final Setting <Boolean > REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING = Setting .boolSetting (
108
- REMOTE_STORE_MIGRATION_EXPERIMENTAL ,
109
- false ,
110
- Property .NodeScope
111
- );
112
-
113
- public static final Setting <Boolean > EXTENSIONS_SETTING = Setting .boolSetting (EXTENSIONS , false , Property .NodeScope );
114
-
115
- public static final Setting <Boolean > IDENTITY_SETTING = Setting .boolSetting (IDENTITY , false , Property .NodeScope );
116
-
117
- public static final Setting <Boolean > TELEMETRY_SETTING = Setting .boolSetting (TELEMETRY , false , Property .NodeScope );
118
-
119
- public static final Setting <Boolean > DATETIME_FORMATTER_CACHING_SETTING = Setting .boolSetting (
120
- DATETIME_FORMATTER_CACHING ,
121
- true ,
122
- Property .NodeScope
123
- );
124
-
125
- public static final Setting <Boolean > WRITEABLE_REMOTE_INDEX_SETTING = Setting .boolSetting (
126
- WRITEABLE_REMOTE_INDEX ,
127
- false ,
128
- Property .NodeScope
129
- );
130
-
131
- public static final Setting <Boolean > PLUGGABLE_CACHE_SETTING = Setting .boolSetting (PLUGGABLE_CACHE , false , Property .NodeScope );
132
158
}
0 commit comments