national_admin_functions #1

Manually merged
michele.artini merged 75 commits from national_admin_functions into master 2020-10-26 08:32:19 +01:00
5 changed files with 56 additions and 27 deletions
Showing only changes of commit b49ec4cc69 - Show all commits

View File

@ -32,7 +32,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@EnableScheduling
@EnableTransactionManagement
@EnableElasticsearchRepositories(basePackageClasses = { Event.class, Notification.class })
@EnableElasticsearchRepositories(basePackageClasses = {
Event.class, Notification.class
})
public class LiteratureBrokerServiceConfiguration extends AbstractElasticsearchConfiguration {
private static final Log log = LogFactory.getLog(LiteratureBrokerServiceConfiguration.class);
@ -50,8 +52,10 @@ public class LiteratureBrokerServiceConfiguration extends AbstractElasticsearchC
@Bean
public RestHighLevelClient elasticsearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo(elasticSearchProperties.getClusterNodes())
.build();
.connectedTo(elasticSearchProperties.getClusterNodes())
.withConnectTimeout(elasticSearchProperties.getConnectionTimeout())
.withSocketTimeout(elasticSearchProperties.getSocketTimeout())
.build();
return RestClients.create(clientConfiguration).rest();
}
@ -60,24 +64,20 @@ public class LiteratureBrokerServiceConfiguration extends AbstractElasticsearchC
log.info("Initializing SWAGGER...");
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(p -> p.startsWith("/api/"))
.build()
.tags(
new Tag(TAG_EVENTS, "Events management"),
new Tag(TAG_SUBSCRIPTIONS, "Subscriptions management"),
new Tag(TAG_NOTIFICATIONS, "Notifications management"),
new Tag(TAG_TOPIC_TYPES, "Topic types management"),
new Tag(TAG_OPENAIRE, "OpenAIRE use case"))
.apiInfo(new ApiInfo(
"Literature Broker Service",
"APIs documentation",
"1.1",
"urn:tos",
ApiInfo.DEFAULT_CONTACT,
"Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0"));
.select()
.apis(RequestHandlerSelectors.any())
.paths(p -> p.startsWith("/api/"))
.build()
.tags(new Tag(TAG_EVENTS, "Events management"), new Tag(TAG_SUBSCRIPTIONS, "Subscriptions management"), new Tag(TAG_NOTIFICATIONS,
"Notifications management"), new Tag(TAG_TOPIC_TYPES, "Topic types management"), new Tag(TAG_OPENAIRE, "OpenAIRE use case"))
.apiInfo(new ApiInfo(
"Literature Broker Service",
"APIs documentation",
"1.1",
"urn:tos",
ApiInfo.DEFAULT_CONTACT,
"Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0"));
}

View File

@ -21,6 +21,10 @@ public class ElasticSearchProperties {
private String notificationsIndexName;
@NotNull
private String notificationsIndexType;
@NotNull
private long connectionTimeout;
@NotNull
private long socketTimeout;
public String getClusterNodes() {
return this.clusterNodes;
@ -70,4 +74,20 @@ public class ElasticSearchProperties {
this.notificationsIndexType = notificationsIndexType;
}
public long getConnectionTimeout() {
return connectionTimeout;
}
public void setConnectionTimeout(final long connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public long getSocketTimeout() {
return socketTimeout;
}
public void setSocketTimeout(final long socketTimeout) {
this.socketTimeout = socketTimeout;
}
}

View File

@ -19,7 +19,7 @@ import eu.dnetlib.lbs.topics.TopicTypeRepository;
public class EventVerifier implements Predicate<Event> {
private final TopicTypeRepository topicTypeRepo;
private final long MAX_DELAY = 5000; // 10 seconds
private final long MAX_DELAY = 30000; // 30 seconds
private Instant last = Instant.EPOCH;
private List<Predicate<Event>> validators = new ArrayList<>();
@ -40,8 +40,8 @@ public class EventVerifier implements Predicate<Event> {
final Iterable<TopicType> iter = this.topicTypeRepo.findAll();
this.validators = StreamSupport.stream(iter.spliterator(), false)
.map(TopicType::asValidator)
.collect(Collectors.toList());
.map(TopicType::asValidator)
.collect(Collectors.toList());
}
try {

View File

@ -23,9 +23,10 @@ lbs.database.url = ${spring.datasource.url}
# for localhost
lbs.elastic.clusterNodes = 127.0.0.1:9200
lbs.elastic.homepage = http://
lbs.elastic.clusterNodes = 127.0.0.1:9200
lbs.elastic.homepage = http://
lbs.elastic.socketTimeout = 30000
lbs.elastic.connectionTimeout = 30000
lbs.elastic.eventsIndexName = oa_events_beta
lbs.elastic.eventsIndexType = event

View File

@ -141,6 +141,14 @@
<th class="col-xs-1">type</th>
<td class="col-xs-3">{{summary.elasticSearch.notificationsIndexType}}</td>
</tr>
<tr>
<th class="col-xs-4">socket timeout</th>
<td class="col-xs-8" colspan="3">{{summary.elasticSearch.socketTimeout}} ms</td>
</tr>
<tr>
<th class="col-xs-4">connection timeout</th>
<td class="col-xs-8" colspan="3">{{summary.elasticSearch.connectionTimeout}} ms</td>
</tr>
</table>
</div>
</div>