8
8
import io .split .engine .common .Synchronizer ;
9
9
import io .split .engine .experiments .RuleBasedSegmentParser ;
10
10
import io .split .engine .experiments .SplitParser ;
11
- import io .split .engine .sse .dtos .FeatureFlagChangeNotification ;
11
+ import io .split .engine .sse .dtos .CommonChangeNotification ;
12
12
import io .split .engine .sse .dtos .IncomingNotification ;
13
- import io .split .engine .sse .dtos .RuleBasedSegmentChangeNotification ;
14
13
import io .split .engine .sse .dtos .SplitKillNotification ;
15
14
import io .split .storages .RuleBasedSegmentCache ;
16
15
import io .split .storages .SplitCacheProducer ;
@@ -67,26 +66,26 @@ protected void executeRefresh(IncomingNotification incomingNotification) {
67
66
long changeNumber = 0L ;
68
67
long changeNumberRBS = 0L ;
69
68
if (incomingNotification .getType () == IncomingNotification .Type .SPLIT_UPDATE ) {
70
- FeatureFlagChangeNotification featureFlagChangeNotification = (FeatureFlagChangeNotification ) incomingNotification ;
69
+ CommonChangeNotification < Split > featureFlagChangeNotification = (CommonChangeNotification ) incomingNotification ;
71
70
success = addOrUpdateFeatureFlag (featureFlagChangeNotification );
72
71
changeNumber = featureFlagChangeNotification .getChangeNumber ();
73
72
} else {
74
- RuleBasedSegmentChangeNotification ruleBasedSegmentChangeNotification = (RuleBasedSegmentChangeNotification ) incomingNotification ;
75
- success = AddOrUpdateRuleBasedSegment (( RuleBasedSegmentChangeNotification ) incomingNotification );
73
+ CommonChangeNotification < RuleBasedSegment > ruleBasedSegmentChangeNotification = (CommonChangeNotification ) incomingNotification ;
74
+ success = AddOrUpdateRuleBasedSegment (ruleBasedSegmentChangeNotification );
76
75
changeNumberRBS = ruleBasedSegmentChangeNotification .getChangeNumber ();
77
76
}
78
77
if (!success )
79
78
_synchronizer .refreshSplits (changeNumber , changeNumberRBS );
80
79
}
81
80
82
- private boolean AddOrUpdateRuleBasedSegment (RuleBasedSegmentChangeNotification ruleBasedSegmentChangeNotification ) {
81
+ private boolean AddOrUpdateRuleBasedSegment (CommonChangeNotification ruleBasedSegmentChangeNotification ) {
83
82
if (ruleBasedSegmentChangeNotification .getChangeNumber () <= _ruleBasedSegmentCache .getChangeNumber ()) {
84
83
return true ;
85
84
}
86
85
try {
87
- if (ruleBasedSegmentChangeNotification .getRuleBasedSegmentDefinition () != null &&
86
+ if (ruleBasedSegmentChangeNotification .getDefinition () != null &&
88
87
ruleBasedSegmentChangeNotification .getPreviousChangeNumber () == _ruleBasedSegmentCache .getChangeNumber ()) {
89
- RuleBasedSegment ruleBasedSegment = ruleBasedSegmentChangeNotification .getRuleBasedSegmentDefinition ();
88
+ RuleBasedSegment ruleBasedSegment = ( RuleBasedSegment ) ruleBasedSegmentChangeNotification .getDefinition ();
90
89
RuleBasedSegmentsToUpdate ruleBasedSegmentsToUpdate = processRuleBasedSegmentChanges (_ruleBasedSegmentParser ,
91
90
Collections .singletonList (ruleBasedSegment ));
92
91
_ruleBasedSegmentCache .update (ruleBasedSegmentsToUpdate .getToAdd (), ruleBasedSegmentsToUpdate .getToRemove (),
@@ -104,14 +103,14 @@ private boolean AddOrUpdateRuleBasedSegment(RuleBasedSegmentChangeNotification r
104
103
}
105
104
return false ;
106
105
}
107
- private boolean addOrUpdateFeatureFlag (FeatureFlagChangeNotification featureFlagChangeNotification ) {
106
+ private boolean addOrUpdateFeatureFlag (CommonChangeNotification featureFlagChangeNotification ) {
108
107
if (featureFlagChangeNotification .getChangeNumber () <= _splitCacheProducer .getChangeNumber ()) {
109
108
return true ;
110
109
}
111
110
try {
112
- if (featureFlagChangeNotification .getFeatureFlagDefinition () != null &&
111
+ if (featureFlagChangeNotification .getDefinition () != null &&
113
112
featureFlagChangeNotification .getPreviousChangeNumber () == _splitCacheProducer .getChangeNumber ()) {
114
- Split featureFlag = featureFlagChangeNotification .getFeatureFlagDefinition ();
113
+ Split featureFlag = ( Split ) featureFlagChangeNotification .getDefinition ();
115
114
FeatureFlagsToUpdate featureFlagsToUpdate = processFeatureFlagChanges (_splitParser , Collections .singletonList (featureFlag ),
116
115
_flagSetsFilter );
117
116
_splitCacheProducer .update (featureFlagsToUpdate .getToAdd (), featureFlagsToUpdate .getToRemove (),
@@ -123,7 +122,7 @@ private boolean addOrUpdateFeatureFlag(FeatureFlagChangeNotification featureFlag
123
122
if (featureFlagsToUpdate .getToAdd ().stream ().count () > 0 ) {
124
123
Set <String > ruleBasedSegments = featureFlagsToUpdate .getToAdd ().get (0 ).getRuleBasedSegmentsNames ();
125
124
if (!ruleBasedSegments .isEmpty () && !_ruleBasedSegmentCache .contains (ruleBasedSegments )) {
126
- _synchronizer . refreshSplits ( featureFlagChangeNotification . getChangeNumber (), 0L ) ;
125
+ return false ;
127
126
}
128
127
}
129
128
_telemetryRuntimeProducer .recordUpdatesFromSSE (UpdatesFromSSEEnum .SPLITS );
0 commit comments