Skip to content

Commit 6d60599

Browse files
authored
Merge pull request #2134 from beyonnex-io/bugfix/fix-config-throttling
fix configuration of throttling of search index update after policy update
2 parents e8ff946 + 4e6538f commit 6d60599

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

base/service/src/main/java/org/eclipse/ditto/base/service/config/ThrottlingConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ enum ConfigValue implements KnownConfigValue {
9090
/**
9191
* Whether throttling should be enabled.
9292
*/
93-
ENABLED("enabled", false),
93+
ENABLED("enabled", true),
9494

9595
/**
9696
* The throttling interval meaning in which duration may the configured

deployment/helm/ditto/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: |
1616
A digital twin is a virtual, cloud based, representation of his real world counterpart
1717
(real world “Things”, e.g. devices like sensors, smart heating, connected cars, smart grids, EV charging stations etc).
1818
type: application
19-
version: 3.7.0 # chart version is effectively set by release-job
19+
version: 3.7.1 # chart version is effectively set by release-job
2020
appVersion: 3.7.0
2121
keywords:
2222
- iot-chart

deployment/helm/ditto/templates/thingssearch-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ spec:
206206
value: "{{ .Values.thingsSearch.config.mongodb.policyModificationCausedSearchIndexUpdateThrottling.enabled }}"
207207
- name: POLICY_MODIFICATION_CAUSED_SEARCH_INDEX_UPDATE_THROTTLING_INTERVAL
208208
value: "{{ .Values.thingsSearch.config.mongodb.policyModificationCausedSearchIndexUpdateThrottling.interval }}"
209-
- name: POLICY_MODIFICATION_CAUSED_SEARCH_INDEX_UPDATE_policyModificationCausedSearchIndexUpdateThrottlingTHROTTLING_LIMIT
209+
- name: POLICY_MODIFICATION_CAUSED_SEARCH_INDEX_UPDATE_THROTTLING_LIMIT
210210
value: "{{ .Values.thingsSearch.config.mongodb.policyModificationCausedSearchIndexUpdateThrottling.limit }}"
211211
- name: THINGS_SEARCH_UPDATER_STREAM_PERSISTENCE_WITH_ACKS_WRITE_CONCERN
212212
value: "{{ .Values.thingsSearch.config.mongodb.searchWithAcksWriteConcern }}"

deployment/helm/ditto/values.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1376,13 +1376,13 @@ thingsSearch:
13761376
updaterPersistenceReadConcern: "local"
13771377
# updaterPersistenceReadPreference configures the MongoDB read preference for the "ThingUpdater"
13781378
updaterPersistenceReadPreference: "primaryPreferred"
1379-
# PolicyModificationCausedSearchIndexUpdateThrottling contains throttling configuration for the search Index update after a policy update
1379+
# policyModificationCausedSearchIndexUpdateThrottling contains throttling configuration for the search Index update after a policy update
13801380
policyModificationCausedSearchIndexUpdateThrottling:
1381-
# enabled defines whether throttling should be applied for search Index update after a policy update.
1382-
enabled: false
1383-
# The time window within which the throttling limit applies.
1381+
# enabled defines whether throttling should be applied for search Index update after a policy update
1382+
enabled: true
1383+
# interval defined the time window within which the throttling limit applies
13841384
interval: 1s
1385-
# The maximum number of updates allowed within each throttling interval.
1385+
# limit is the maximum number of updates allowed within each throttling interval
13861386
limit: 100
13871387
# updater contains configuration for the "Things Updater" of things-search service
13881388
updater:

thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/persistence/write/impl/MongoThingsSearchUpdaterPersistence.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import java.util.Set;
2626
import java.util.stream.Collectors;
2727

28+
import org.apache.pekko.NotUsed;
29+
import org.apache.pekko.japi.pf.PFBuilder;
30+
import org.apache.pekko.stream.javadsl.Source;
2831
import org.bson.BsonDateTime;
2932
import org.bson.BsonDocument;
3033
import org.bson.BsonInt32;
@@ -48,22 +51,20 @@
4851
import com.mongodb.reactivestreams.client.MongoCollection;
4952
import com.mongodb.reactivestreams.client.MongoDatabase;
5053

51-
import org.apache.pekko.NotUsed;
52-
import org.apache.pekko.japi.pf.PFBuilder;
53-
import org.apache.pekko.stream.javadsl.Source;
54-
5554
/**
5655
* MongoDB specific implementation of the {@link org.eclipse.ditto.thingsearch.service.persistence.write.ThingsSearchUpdaterPersistence}.
5756
*/
5857
public final class MongoThingsSearchUpdaterPersistence implements ThingsSearchUpdaterPersistence {
5958

6059
private final MongoCollection<Document> collection;
6160

62-
private final ThrottlingConfig PolicyModificationCausedSearchIndexUpdateThrottling;
61+
private final ThrottlingConfig policyModificationCausedSearchIndexUpdateThrottling;
6362

6463
private MongoThingsSearchUpdaterPersistence(final MongoDatabase database,
65-
final SearchPersistenceConfig updaterPersistenceConfig) {
66-
this.PolicyModificationCausedSearchIndexUpdateThrottling = updaterPersistenceConfig.getPolicyModificationCausedSearchIndexUpdateThrottling();
64+
final SearchPersistenceConfig updaterPersistenceConfig)
65+
{
66+
this.policyModificationCausedSearchIndexUpdateThrottling = updaterPersistenceConfig
67+
.getPolicyModificationCausedSearchIndexUpdateThrottling();
6768

6869
collection = database.getCollection(PersistenceConstants.THINGS_COLLECTION_NAME)
6970
.withReadConcern(updaterPersistenceConfig.readConcern().getMongoReadConcern())
@@ -111,10 +112,10 @@ public Source<PolicyReferenceTag, NotUsed> getPolicyReferenceTags(final Map<Poli
111112
.append(PersistenceConstants.FIELD_REFERENCED_POLICIES, new BsonInt32(1)));
112113

113114

114-
final Source<Document, NotUsed> throttledSource = PolicyModificationCausedSearchIndexUpdateThrottling.isEnabled()
115+
final Source<Document, NotUsed> throttledSource = policyModificationCausedSearchIndexUpdateThrottling.isEnabled()
115116
? Source.fromPublisher(publisher).throttle(
116-
PolicyModificationCausedSearchIndexUpdateThrottling.getLimit(),
117-
PolicyModificationCausedSearchIndexUpdateThrottling.getInterval()
117+
policyModificationCausedSearchIndexUpdateThrottling.getLimit(),
118+
policyModificationCausedSearchIndexUpdateThrottling.getInterval()
118119
)
119120
: Source.fromPublisher(publisher);
120121

thingsearch/service/src/main/resources/search.conf

+6-4
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,18 @@ ditto {
299299
# read concern is one of: default, local, majority, linearizable, snapshot, available
300300
readConcern = ${ditto.mongodb.options.readConcern}
301301
readConcern = ${?UPDATER_PERSISTENCE_MONGO_DB_READ_CONCERN}
302-
# PolicyModificationCausedSearchIndexUpdateThrottling contains throttling configuration for the search Index update after a policy update
302+
303+
# policyModificationCausedSearchIndexUpdateThrottling contains throttling configuration for the search Index update after a policy update
303304
policyModificationCausedSearchIndexUpdateThrottling {
304-
# enabled defines whether throttling should be applied for search Index update after a policy update.
305+
# enabled defines whether throttling should be applied for search Index update after a policy update
305306
enabled = false
306307
enabled = ${?POLICY_MODIFICATION_CAUSED_SEARCH_INDEX_UPDATE_THROTTLING_ENABLED}
307-
# The interval at which updates are throttled (e.g., every 1 second)
308+
309+
# interval at which updates are throttled (e.g., every 1 second)
308310
interval = 1s
309311
interval = ${?POLICY_MODIFICATION_CAUSED_SEARCH_INDEX_UPDATE_THROTTLING_INTERVAL}
310312

311-
# Maximum number of updates allowed per interval (e.g., 100 updates per second)
313+
# limit is the maximum number of updates allowed per interval (e.g., 100 updates per second)
312314
limit = 100
313315
limit = ${?POLICY_MODIFICATION_CAUSED_SEARCH_INDEX_UPDATE_THROTTLING_LIMIT}
314316
}

0 commit comments

Comments
 (0)