optimizations of es settings

This commit is contained in:
Michele Artini 2020-07-28 11:30:06 +02:00
parent b49ec4cc69
commit 81ed82683d
7 changed files with 69 additions and 44 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
@Document(indexName = "#{elasticSearchProperties.eventsIndexName}", type = "#{elasticSearchProperties.eventsIndexType}") @Document(indexName = "#{elasticSearchProperties.eventsIndexName}", shards = 48, replicas = 0, refreshInterval = "600s")
public class Event { public class Event {
@Id @Id
@ -37,8 +37,8 @@ public class Event {
public Event() {} public Event() {}
public Event(final String producerId, final String eventId, final String topic, final String payload, final Long creationDate, final Long expiryDate, public Event(final String producerId, final String eventId, final String topic, final String payload, final Long creationDate, final Long expiryDate,
final boolean instantMessage, final boolean instantMessage,
final Map<String, Object> map) { final Map<String, Object> map) {
this.producerId = producerId; this.producerId = producerId;
this.eventId = eventId; this.eventId = eventId;
this.topic = topic; this.topic = topic;

View File

@ -11,7 +11,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
import eu.dnetlib.lbs.subscriptions.Subscription; import eu.dnetlib.lbs.subscriptions.Subscription;
@Document(indexName = "#{elasticSearchProperties.notificationsIndexName}", type = "#{elasticSearchProperties.notificationsIndexType}") @Document(indexName = "#{elasticSearchProperties.notificationsIndexName}", shards = 48, replicas = 0, refreshInterval = "600s")
public class Notification { public class Notification {
@Id @Id
@ -41,8 +41,8 @@ public class Notification {
public Notification() {} public Notification() {}
public Notification(final String notificationId, final String subscriptionId, final String producerId, final String eventId, final String topic, public Notification(final String notificationId, final String subscriptionId, final String producerId, final String eventId, final String topic,
final String payload, final String payload,
final Map<String, Object> map, final Long date) { final Map<String, Object> map, final Long date) {
super(); super();
this.notificationId = notificationId; this.notificationId = notificationId;
this.subscriptionId = subscriptionId; this.subscriptionId = subscriptionId;
@ -56,13 +56,13 @@ public class Notification {
public Notification(final Subscription s, final Event e) { public Notification(final Subscription s, final Event e) {
this(Notification.calculateId(s, e), this(Notification.calculateId(s, e),
s.getSubscriptionId(), s.getSubscriptionId(),
e.getProducerId(), e.getProducerId(),
e.getEventId(), e.getEventId(),
e.getTopic(), e.getTopic(),
e.getPayload(), e.getPayload(),
e.getMap(), e.getMap(),
new Date().getTime()); new Date().getTime());
} }
public String getNotificationId() { public String getNotificationId() {

View File

@ -110,8 +110,6 @@ public class SubscriptionEventMatcher implements Runnable {
.must(QueryBuilders.rangeQuery("creationDate").from(s.getLastNotificationDate() != null ? s.getLastNotificationDate().getTime() : 0)) .must(QueryBuilders.rangeQuery("creationDate").from(s.getLastNotificationDate() != null ? s.getLastNotificationDate().getTime() : 0))
.must(QueryBuilders.nestedQuery("map", mapQuery, ScoreMode.None))) .must(QueryBuilders.nestedQuery("map", mapQuery, ScoreMode.None)))
.withSearchType(SearchType.DEFAULT) .withSearchType(SearchType.DEFAULT)
// .withIndices(elasticSearchProperties.getEventsIndexName())
// .withTypes(elasticSearchProperties.getEventsIndexType())
.withPageable(PageRequest.of(0, 10)) .withPageable(PageRequest.of(0, 10))
.build(); .build();

View File

@ -16,12 +16,8 @@ public class ElasticSearchProperties {
@NotNull @NotNull
private String eventsIndexName; private String eventsIndexName;
@NotNull @NotNull
private String eventsIndexType;
@NotNull
private String notificationsIndexName; private String notificationsIndexName;
@NotNull @NotNull
private String notificationsIndexType;
@NotNull
private long connectionTimeout; private long connectionTimeout;
@NotNull @NotNull
private long socketTimeout; private long socketTimeout;
@ -50,14 +46,6 @@ public class ElasticSearchProperties {
this.eventsIndexName = eventsIndexName; this.eventsIndexName = eventsIndexName;
} }
public String getEventsIndexType() {
return this.eventsIndexType;
}
public void setEventsIndexType(final String eventsIndexType) {
this.eventsIndexType = eventsIndexType;
}
public String getNotificationsIndexName() { public String getNotificationsIndexName() {
return this.notificationsIndexName; return this.notificationsIndexName;
} }
@ -66,14 +54,6 @@ public class ElasticSearchProperties {
this.notificationsIndexName = notificationsIndexName; this.notificationsIndexName = notificationsIndexName;
} }
public String getNotificationsIndexType() {
return this.notificationsIndexType;
}
public void setNotificationsIndexType(final String notificationsIndexType) {
this.notificationsIndexType = notificationsIndexType;
}
public long getConnectionTimeout() { public long getConnectionTimeout() {
return connectionTimeout; return connectionTimeout;
} }

View File

@ -27,11 +27,8 @@ lbs.elastic.clusterNodes = 127.0.0.1:9200
lbs.elastic.homepage = http:// lbs.elastic.homepage = http://
lbs.elastic.socketTimeout = 30000 lbs.elastic.socketTimeout = 30000
lbs.elastic.connectionTimeout = 30000 lbs.elastic.connectionTimeout = 30000
lbs.elastic.eventsIndexName = oa_events_beta lbs.elastic.eventsIndexName = oa_events_beta
lbs.elastic.eventsIndexType = event
lbs.elastic.notificationsIndexName = oa_notifications_beta lbs.elastic.notificationsIndexName = oa_notifications_beta
lbs.elastic.notificationsIndexType = notification
lbs.mail.from = notifications-noreply@openaire.eu lbs.mail.from = notifications-noreply@openaire.eu
lbs.mail.fromName = Literature Broker Service lbs.mail.fromName = Literature Broker Service

View File

@ -4,6 +4,57 @@ INDEXBASEURL=http://localhost:9200
EVENTINDEXNAME=oa_events_beta EVENTINDEXNAME=oa_events_beta
NOTIFICATIONINDEXNAME=oa_notifications_beta NOTIFICATIONINDEXNAME=oa_notifications_beta
echo
echo "Update settings of events index..."
curl -XPOST "$INDEXBASEURL/$EVENTINDEXNAME/_close"
echo
curl -XPUT -H 'Content-Type: application/json' "$INDEXBASEURL/$EVENTINDEXNAME/_settings" -d '
{
"index": {
"translog": {
"sync_interval": "15s",
"durability": "ASYNC"
},
"analysis": {
"analyzer": {
"analyzer_keyword": {
"filter": "lowercase",
"tokenizer": "keyword"
}
}
}
}
}'
echo
curl -XPOST "$INDEXBASEURL/$EVENTINDEXNAME/_open"
echo
echo
echo "Update settings of notifications index..."
curl -XPOST "$INDEXBASEURL/$NOTIFICATIONINDEXNAME/_close"
echo
curl -XPUT -H 'Content-Type: application/json' "$INDEXBASEURL/$NOTIFICATIONINDEXNAME/_settings" -d '
{
"index": {
"translog": {
"sync_interval": "15s",
"durability": "ASYNC"
},
"analysis": {
"analyzer": {
"analyzer_keyword": {
"filter": "lowercase",
"tokenizer": "keyword"
}
}
}
}
}'
echo
curl -XPOST "$INDEXBASEURL/$NOTIFICATIONINDEXNAME/_open"
echo
echo echo
echo "Fixing events index..." echo "Fixing events index..."
curl -XPUT -H 'Content-Type: application/json' "$INDEXBASEURL/$EVENTINDEXNAME/_mapping" -d ' curl -XPUT -H 'Content-Type: application/json' "$INDEXBASEURL/$EVENTINDEXNAME/_mapping" -d '
@ -54,3 +105,6 @@ curl -XPUT -H 'Content-Type: application/json' "$INDEXBASEURL/$NOTIFICATIONINDEX
} }
} }
}' }'
echo
echo

View File

@ -133,13 +133,9 @@
</tr> </tr>
<tr> <tr>
<th class="col-xs-4" rowspan="2">indexes</th> <th class="col-xs-4" rowspan="2">indexes</th>
<td class="col-xs-4">{{summary.elasticSearch.eventsIndexName}}</td> <td class="col-xs-8">{{summary.elasticSearch.eventsIndexName}}</td>
<th class="col-xs-1">type</th>
<td class="col-xs-3">{{summary.elasticSearch.eventsIndexType}}</td>
<tr> <tr>
<td class="col-xs-4">{{summary.elasticSearch.notificationsIndexName}}</td> <td class="col-xs-8">{{summary.elasticSearch.notificationsIndexName}}</td>
<th class="col-xs-1">type</th>
<td class="col-xs-3">{{summary.elasticSearch.notificationsIndexType}}</td>
</tr> </tr>
<tr> <tr>
<th class="col-xs-4">socket timeout</th> <th class="col-xs-4">socket timeout</th>