17
17
18
18
import com .optimizely .ab .annotations .VisibleForTesting ;
19
19
import com .optimizely .ab .config .*;
20
- import org .slf4j .Logger ;
21
- import org .slf4j .LoggerFactory ;
22
20
import java .util .*;
23
21
import java .util .function .Function ;
24
22
import java .util .stream .Collectors ;
25
23
26
24
public class OptimizelyConfigService {
27
25
28
- private static final Logger logger = LoggerFactory .getLogger (OptimizelyConfigService .class );
29
26
private ProjectConfig projectConfig ;
30
27
private OptimizelyConfig optimizelyConfig ;
31
28
@@ -36,9 +33,7 @@ public OptimizelyConfigService(ProjectConfig projectConfig) {
36
33
this .projectConfig = projectConfig ;
37
34
this .featureKeyToVariablesMap = generateFeatureKeyToVariablesMap ();
38
35
39
- logger .info ("Getting experiment map for project config" );
40
36
Map <String , OptimizelyExperiment > experimentsMap = getExperimentsMap ();
41
- logger .info ("Creating the complete optimizely config" );
42
37
optimizelyConfig = new OptimizelyConfig (
43
38
experimentsMap ,
44
39
getFeaturesMap (experimentsMap ),
@@ -63,7 +58,6 @@ public OptimizelyConfig getConfig() {
63
58
Map <String , List <FeatureVariable >> generateFeatureKeyToVariablesMap () {
64
59
List <FeatureFlag > featureFlags = projectConfig .getFeatureFlags ();
65
60
if (featureFlags == null ) {
66
- logger .warn ("Returning empty map because there are no feature flags in project config" );
67
61
return Collections .emptyMap ();
68
62
}
69
63
return featureFlags .stream ().collect (Collectors .toMap (FeatureFlag ::getKey , featureFlag -> featureFlag .getVariables ()));
@@ -72,15 +66,13 @@ Map<String, List<FeatureVariable>> generateFeatureKeyToVariablesMap() {
72
66
@ VisibleForTesting
73
67
String getExperimentFeatureKey (String experimentId ) {
74
68
List <String > featureKeys = projectConfig .getExperimentFeatureKeyMapping ().get (experimentId );
75
- logger .info ("Keys for feature experiment is null {}" , featureKeys == null );
76
69
return featureKeys != null ? featureKeys .get (0 ) : null ;
77
70
}
78
71
79
72
@ VisibleForTesting
80
73
Map <String , OptimizelyExperiment > getExperimentsMap () {
81
74
List <Experiment > experiments = projectConfig .getExperiments ();
82
75
if (experiments == null ) {
83
- logger .warn ("Returning empty map because there are no experiments in project config" );
84
76
return Collections .emptyMap ();
85
77
}
86
78
return experiments .stream ().collect (Collectors .toMap (Experiment ::getKey , experiment -> new OptimizelyExperiment (
@@ -93,11 +85,9 @@ Map<String, OptimizelyExperiment> getExperimentsMap() {
93
85
@ VisibleForTesting
94
86
Map <String , OptimizelyVariation > getVariationsMap (List <Variation > variations , String experimentId ) {
95
87
if (variations == null ) {
96
- logger .warn ("Returning empty map because there variations provided are null" );
97
88
return Collections .emptyMap ();
98
89
}
99
90
Boolean isFeatureExperiment = this .getExperimentFeatureKey (experimentId ) != null ;
100
- logger .debug ("Experiment id {} is a feature experiment: {}" , experimentId , isFeatureExperiment );
101
91
return variations .stream ().collect (Collectors .toMap (Variation ::getKey , variation -> new OptimizelyVariation (
102
92
variation .getId (),
103
93
variation .getKey (),
@@ -116,15 +106,13 @@ Map<String, OptimizelyVariation> getVariationsMap(List<Variation> variations, St
116
106
Map <String , OptimizelyVariable > getMergedVariablesMap (Variation variation , String experimentId ) {
117
107
String featureKey = this .getExperimentFeatureKey (experimentId );
118
108
if (featureKey != null ) {
119
- logger .info ("Merging the variables as feature key is available" );
120
109
// Generate temp map of all the available variable values from variation.
121
110
Map <String , OptimizelyVariable > tempVariableIdMap = getFeatureVariableUsageInstanceMap (variation .getFeatureVariableUsageInstances ());
122
111
123
112
// Iterate over all the variables available in associated feature.
124
113
// Use value from variation variable if variable is available in variation and feature is enabled, otherwise use defaultValue from feature variable.
125
114
List <FeatureVariable > featureVariables = featureKeyToVariablesMap .get (featureKey );
126
115
if (featureVariables == null ) {
127
- logger .warn ("Returning empty map as featureKeyToVariablesMap is null" );
128
116
return Collections .emptyMap ();
129
117
}
130
118
@@ -143,7 +131,6 @@ Map<String, OptimizelyVariable> getMergedVariablesMap(Variation variation, Strin
143
131
@ VisibleForTesting
144
132
Map <String , OptimizelyVariable > getFeatureVariableUsageInstanceMap (List <FeatureVariableUsageInstance > featureVariableUsageInstances ) {
145
133
if (featureVariableUsageInstances == null ) {
146
- logger .warn ("Returning empty map because there FeatureVariableUsageInstance provided are null" );
147
134
return Collections .emptyMap ();
148
135
}
149
136
return featureVariableUsageInstances .stream ().collect (Collectors .toMap (FeatureVariableUsageInstance ::getId , variable -> new OptimizelyVariable (
@@ -158,7 +145,6 @@ Map<String, OptimizelyVariable> getFeatureVariableUsageInstanceMap(List<FeatureV
158
145
Map <String , OptimizelyFeature > getFeaturesMap (Map <String , OptimizelyExperiment > allExperimentsMap ) {
159
146
List <FeatureFlag > featureFlags = projectConfig .getFeatureFlags ();
160
147
if (featureFlags == null ) {
161
- logger .warn ("Returning empty map because there are no feature flags in project config" );
162
148
return Collections .emptyMap ();
163
149
}
164
150
return featureFlags .stream ().collect (Collectors .toMap (FeatureFlag ::getKey , featureFlag -> new OptimizelyFeature (
@@ -172,7 +158,6 @@ Map<String, OptimizelyFeature> getFeaturesMap(Map<String, OptimizelyExperiment>
172
158
@ VisibleForTesting
173
159
Map <String , OptimizelyExperiment > getExperimentsMapForFeature (List <String > experimentIds , Map <String , OptimizelyExperiment > allExperimentsMap ) {
174
160
if (experimentIds == null ) {
175
- logger .warn ("Returning empty map because the experiment id list is null" );
176
161
return Collections .emptyMap ();
177
162
}
178
163
@@ -186,7 +171,6 @@ Map<String, OptimizelyExperiment> getExperimentsMapForFeature(List<String> exper
186
171
@ VisibleForTesting
187
172
Map <String , OptimizelyVariable > getFeatureVariablesMap (List <FeatureVariable > featureVariables ) {
188
173
if (featureVariables == null ) {
189
- logger .warn ("Returning empty map because the feature variables list is null" );
190
174
return Collections .emptyMap ();
191
175
}
192
176
return featureVariables .stream ().collect (Collectors .toMap (FeatureVariable ::getKey , featureVariable -> new OptimizelyVariable (
0 commit comments