Skip to content

Commit 0937cc2

Browse files
authored
Change Event and Aggreagations threads to use only one threadpool (#475)
* Change threads to use only one threadpool * indentation fix * Fix ttl duplication bug in EI infromation * More ttl fix * Remove ttl fix, since it seems to fail tests indirect * Increased threadpool size * Changed back threadpool size for travis test failures * change threadpool parameter * Changed back thread queue capacity * removed a ttl config value that might cause test failures * thread pools config tweak * Fix the minor duplication AggregationTTl values in information restapi * fix default MongoDb connection configuration in case of MongoDB connection is lost and comes back * Fixed MongoDb Client object to not get closed state when connection goes down and comes up * Remove some mongodb parameters that is not needed * Removed unused private function * Removed some default mongodb connection flags that is not needed
1 parent d78a644 commit 0937cc2

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

src/main/java/com/ericsson/ei/handlers/ObjectHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.List;
2222

2323
import com.ericsson.ei.mongo.*;
24+
import com.fasterxml.jackson.annotation.JsonIgnore;
2425
import org.apache.commons.lang3.StringUtils;
2526
import org.bson.Document;
2627
import org.slf4j.Logger;
@@ -274,6 +275,7 @@ public String lockDocument(String id) {
274275
*
275276
* @return ttl Integer value representing time to live for documents
276277
*/
278+
@JsonIgnore
277279
public int getTtl() {
278280
int ttl = 0;
279281
if (StringUtils.isNotEmpty(aggregationsTtl)) {

src/main/java/com/ericsson/ei/mongo/MongoDBHandler.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ private List<String> getCollectionList(String databaseName) throws MongoClientEx
392392
} catch (MongoInterruptedException | MongoSocketReadException | MongoSocketWriteException
393393
| MongoCommandException | IllegalStateException e) {
394394
String message = String.format("Failed to get Mongo collection list, Reason: %s",
395-
e.getMessage());
396-
closeMongoDbConnection();
395+
e.getMessage());
397396
throw new MongoClientException(message, e);
398397
}
399398
}
@@ -435,11 +434,4 @@ private void checkIfCollectionExistError(String databaseName, String collectionN
435434
throw new MongoClientException(message, e);
436435
}
437436
}
438-
439-
private void closeMongoDbConnection() {
440-
if (mongoClient != null) {
441-
mongoClient.close();
442-
}
443-
mongoClient = null;
444-
}
445437
}

src/main/java/com/ericsson/ei/subscription/SubscriptionHandler.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,11 @@ public class SubscriptionHandler {
7474
*/
7575
public void checkSubscriptionForObject(final String aggregatedObject,
7676
final String id) {
77-
Thread subscriptionThread = new Thread(() -> {
78-
List<String> subscriptions = mongoDBHandler.getAllDocuments(
79-
database, subscriptionCollectionName);
80-
subscriptions.forEach(
77+
List<String> subscriptions = mongoDBHandler.getAllDocuments(
78+
database, subscriptionCollectionName);
79+
subscriptions.forEach(
8180
subscription -> extractConditions(aggregatedObject,
82-
subscription, id));
83-
});
84-
subscriptionThread.setName("SubscriptionHandler");
85-
subscriptionThread.start();
81+
subscription, id));
8682
}
8783

8884
/**

src/main/resources/application.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ spring.mongodb.embedded.version: 3.4.1
7575
# starts and activate it manually in tests where we need the Spring's own embedded mongo DB
7676
spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration
7777

78-
threads.core.pool.size: 100
79-
threads.queue.capacity: 5000
80-
threads.max.pool.size: 150
81-
scheduled.threadpool.size: 100
78+
threads.core.pool.size: 200
79+
threads.queue.capacity: 7000
80+
threads.max.pool.size: 250
81+
scheduled.threadpool.size: 200

0 commit comments

Comments
 (0)