Skip to content

Commit

Permalink
Change version to 0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
etorres committed Dec 30, 2015
1 parent ff0079b commit 0c69017
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="lvl-storage-0.9.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-storage/lvl-storage">
<dependent-module archiveName="lvl-storage-0.9.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-storage/lvl-storage">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="lvl-core-0.9.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-core/lvl-core">
<dependent-module archiveName="lvl-core-0.9.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-core/lvl-core">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/lvl-auth/target/classes"/>
Expand Down
2 changes: 1 addition & 1 deletion lvl-project/lvl-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file.
<parent>
<groupId>eu.eubrazilcc.lvl</groupId>
<artifactId>lvl-project</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion lvl-project/lvl-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file.
<parent>
<groupId>eu.eubrazilcc.lvl</groupId>
<artifactId>lvl-project</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
1 change: 1 addition & 0 deletions lvl-project/lvl-bundle/src/main/etc/lvl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ that you distribute must include a readable copy of the "NOTICE" text file.
<concept>http://rs.tdwg.org/dwc/dwcore/CollectionCode</concept>
<filter>http://rs.tdwg.org/dwc/dwcore/CollectionCode equals "$COLLECTION"</filter>
<orderby>http://rs.tdwg.org/dwc/dwcore/CatalogNumber</orderby>
<maxElements>3000</maxElements>
<collections>
<collection>clioc:FIOCRUZ-CLIOC</collection>
<collection>colfleb:FIOCRUZ-COLFLEB</collection>
Expand Down
2 changes: 1 addition & 1 deletion lvl-project/lvl-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file.
<parent>
<groupId>eu.eubrazilcc.lvl</groupId>
<artifactId>lvl-project</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public String toString() {
.add("links", links)
.add("urlSafeId", urlSafeInstanceId)
.add("instanceId", instanceId)
.add("roles",roles)
.add("roles", roles)
.add("heartbeat", heartbeat.orNull())
.add("location", location)
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private Configuration configuration() {
final String portalEndpoint = getString("portal.endpoint", configuration, foundNameList, null);
final String wfHostname = getString("workflow.endpoint.hostname", configuration, foundNameList, "localhost");
final boolean wfSecure = getBoolean("workflow.endpoint.secure", configuration, foundNameList, false);
final int wfPort = getInteger("workflow.endpoint.port", configuration, foundNameList, wfSecure ? 443 : 80);
final int wfPort = getInteger("workflow.endpoint.port", configuration, foundNameList, wfSecure ? 443 : 80);
final String wfUsername = getString("workflow.credentials.username", configuration, foundNameList, null);
final String wfPasswd = getString("workflow.credentials.password", configuration, foundNameList, null);
// get secondary property will return null if the requested property is missing
Expand Down Expand Up @@ -412,6 +412,7 @@ public String apply(final Object obj) {
final String concept = getString(name + ".concept", configuration, foundNameList, null);
final String filter = getString(name + ".filter", configuration, foundNameList, null);
final String orderby = getString(name + ".orderby", configuration, foundNameList, null);
final int maxElements = getInteger(name + ".maxElements", configuration, foundNameList, 3000);
final List<String> collections = getStringList(name + ".collections.collection", Pattern.compile("^[\\w]+:[\\w-]+$"), configuration, foundNameList, null);
final Map<String, String> collectionsMap = newHashMap();
if (collections != null) {
Expand All @@ -420,7 +421,7 @@ public String apply(final Object obj) {
collectionsMap.put(tokens[0], tokens[1]);
}
}
return new TapirCollection(url, outputModel, concept, filter, orderby, collectionsMap);
return new TapirCollection(url, outputModel, concept, filter, orderby, maxElements, collectionsMap);
}

private static String subsEnvVars(final String path, final boolean ensureWriting) {
Expand Down Expand Up @@ -670,15 +671,17 @@ public static class TapirCollection {
private final String concept;
private final String filter;
private final String orderby;
private final int maxElements;
private final Map<String, String> collections;

public TapirCollection(final URL url, final String outputModel, final String concept, final String filter, final String orderby,
final Map<String, String> collections) {
final int maxElements, final Map<String, String> collections) {
this.url = url;
this.outputModel = outputModel;
this.concept = concept;
this.filter = filter;
this.orderby = orderby;
this.maxElements = maxElements;
this.collections = collections;
}

Expand All @@ -701,6 +704,10 @@ public String getFilter() {
public String getOrderby() {
return orderby;
}

public int getMaxElements() {
return maxElements;
}

public Map<String, String> getCollections() {
return collections;
Expand All @@ -714,6 +721,7 @@ public String toString() {
.add("concept", concept)
.add("filter", filter)
.add("orderby", orderby)
.add("maxElements", maxElements)
.add("collections", collections)
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,34 @@ public long getKeepAliveDuration(final HttpResponse response, final HttpContext
}
};
private final CloseableHttpClient httpClient;
private final List<Http1_1Request> requests = synchronizedList(new ArrayList<Http1_1Request>());
private final List<Http1_1Request> requests = synchronizedList(new ArrayList<Http1_1Request>());

private HttpClientProvider() {
this(-1);
}

private HttpClientProvider(final int timeoutMs) {
final ConnectionConfig connConfig = ConnectionConfig.custom()
.setCharset(Consts.UTF_8)
.build();
connManager.setDefaultConnectionConfig(connConfig);
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(10);
final RequestConfig requestConfig = timeoutMs > 0 ? defaultRequestConfig(timeoutMs) : RequestConfig.DEFAULT;
httpClient = HttpClients.custom()
.setConnectionManager(connManager)
.setKeepAliveStrategy(keepAliveStrategy)
.setDefaultRequestConfig(requestConfig)
.evictExpiredConnections()
.evictIdleConnections(30l, TimeUnit.SECONDS)
.evictIdleConnections(timeoutMs > 0 ? timeoutMs/1000l : 30l, TimeUnit.SECONDS)
.build();
}

private static RequestConfig defaultRequestConfig(final int timeoutMs) {
return RequestConfig.copy(RequestConfig.DEFAULT)
.setSocketTimeout(timeoutMs)
.setConnectTimeout(timeoutMs)
.setConnectionRequestTimeout(timeoutMs)
.build();
}

Expand Down Expand Up @@ -141,7 +155,11 @@ public void dispose(final Http1_1Request request) {
}

public static HttpClientProvider create() {
return new HttpClientProvider();
return create(-1);
}

public static HttpClientProvider create(final int timeoutMs) {
return new HttpClientProvider(timeoutMs);
}

@Override
Expand Down Expand Up @@ -253,7 +271,7 @@ public Void handleResponse(final HttpResponse response) throws IOException {
}

private HttpUriRequest createHttpRequest() {
HttpUriRequest httpRequest = null;
HttpUriRequest httpRequest = null;
if (HttpGet.METHOD_NAME.equals(method)) {
httpRequest = RequestBuilder.get(uri)
.setVersion(HttpVersion.HTTP_1_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ public abstract class TapirClient implements AutoCloseable {
public static final String XPATH_TO_DWCSET = "/*[local-name()=\"response\"]"
+ "/*[local-name()=\"search\"]"
+ "/*[local-name()=\"SimpleDarwinRecordSet\"]";

public static final int TIMEOUT_MS = 120000;

private final HttpClientProvider httpClient = HttpClientProvider.create();
private final HttpClientProvider httpClient = HttpClientProvider.create(TIMEOUT_MS);

protected ResponseType count(final String url, final String concept, final String filter) throws URISyntaxException, IOException {
final URIBuilder uriBuilder = new URIBuilder(url);
Expand All @@ -83,7 +85,6 @@ protected ResponseType count(final String url, final String concept, final Strin
uriBuilder.addParameter("concept", concept);
uriBuilder.addParameter("filter", filter);
final String url2 = uriBuilder.build().toString();
final HttpClientProvider httpClient = HttpClientProvider.create();
return httpClient.request(url2).get().handleResponse(new ResponseHandler<ResponseType>() {
@Override
public ResponseType handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
Expand Down
3 changes: 2 additions & 1 deletion lvl-project/lvl-core/src/main/resources/lvl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ that you distribute must include a readable copy of the "NOTICE" text file.
<concept>http://rs.tdwg.org/dwc/dwcore/CollectionCode</concept>
<filter>http://rs.tdwg.org/dwc/dwcore/CollectionCode equals "$COLLECTION"</filter>
<orderby>http://rs.tdwg.org/dwc/dwcore/CatalogNumber</orderby>
<maxElements>3000</maxElements>
<collections>
<collection>clioc:FIOCRUZ-CLIOC</collection>
<collection>colfleb:FIOCRUZ-COLFLEB</collection>
</collections>
</collections>
</speciesLink>

</config>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
public class TapirTest extends LeishvlTestCase {

public TapirTest() {
super(true);
super(false);
}

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="lvl-storage-0.9.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-storage/lvl-storage">
<dependent-module archiveName="lvl-storage-0.9.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-storage/lvl-storage">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="lvl-core-0.9.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-core/lvl-core">
<dependent-module archiveName="lvl-core-0.9.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/lvl-core/lvl-core">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="lvl-service"/>
Expand Down
2 changes: 1 addition & 1 deletion lvl-project/lvl-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ that you distribute must include a readable copy of the "NOTICE" text file.
<parent>
<groupId>eu.eubrazilcc.lvl</groupId>
<artifactId>lvl-project</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static eu.eubrazilcc.lvl.core.concurrent.TaskStorage.TASK_STORAGE;
import static eu.eubrazilcc.lvl.core.conf.ConfigurationFinder.findConfigurationFiles;
import static eu.eubrazilcc.lvl.core.conf.ConfigurationManager.CONFIG_MANAGER;
import static eu.eubrazilcc.lvl.service.cache.CacheWarmer.CACHE_WARMER;
import static eu.eubrazilcc.lvl.service.workflow.esc.ESCentralConnector.ESCENTRAL_CONN;
import static eu.eubrazilcc.lvl.storage.activemq.ActiveMQConnector.ACTIVEMQ_CONN;
import static eu.eubrazilcc.lvl.storage.mongodb.MongoDBConnector.MONGODB_CONN;
Expand Down Expand Up @@ -75,6 +76,9 @@ public void preload() {
// load e-SC connector and register it for closing
ESCENTRAL_CONN.preload();
register(ESCENTRAL_CONN);
// load cache warmer and register it for closing
CACHE_WARMER.preload();
register(CACHE_WARMER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2014-2015 EUBrazilCC (EU‐Brazil Cloud Connect)
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
*/

package eu.eubrazilcc.lvl.service.cache;

import static eu.eubrazilcc.lvl.core.concurrent.TaskScheduler.TASK_SCHEDULER;
import static eu.eubrazilcc.lvl.service.cache.GeolocationCache.findNearbyLeishmaniaSequences;
import static eu.eubrazilcc.lvl.service.cache.GeolocationCache.findNearbySandflySequences;
import static eu.eubrazilcc.lvl.service.cache.StatisticsCache.leishmaniaStats;
import static eu.eubrazilcc.lvl.service.cache.StatisticsCache.sandflyStats;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.net.URL;
import java.util.Collection;
import java.util.concurrent.TimeUnit;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;

import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.media.sse.SseFeature;
import org.slf4j.Logger;

import eu.eubrazilcc.lvl.core.Closeable2;
import eu.eubrazilcc.lvl.core.geojson.LngLatAlt;
import eu.eubrazilcc.lvl.core.geojson.Point;
import eu.eubrazilcc.lvl.service.rest.jackson.MapperProvider;

/**
* Warms up (or pre-populates) a cache with record updates.
* @author Erik Torres <[email protected]>
*/
public enum CacheWarmer implements Closeable2 {

CACHE_WARMER;

private static final Logger LOGGER = getLogger(CacheWarmer.class);

private static final String BASE_URI = "http://localhost/lvl-service/rest/v1";

@Override
public void setup(final Collection<URL> urls) { }

@Override
public void preload() {
// create client
final Client client = ClientBuilder.newBuilder()
.register(MapperProvider.class)
.register(JacksonFeature.class)
.register(SseFeature.class)
.register(MultiPartFeature.class)
.build();
final WebTarget target = client.target(BASE_URI);
target.property(ClientProperties.FOLLOW_REDIRECTS, true);
// schedule periodic updates
TASK_SCHEDULER.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
// sandflies global vector and heat maps, collection statistics
findNearbySandflySequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(),
6500000.0, true, false);
findNearbySandflySequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(),
6500000.0, true, true);
sandflyStats();
// leishmania global vector and heat maps, collection statistics
findNearbyLeishmaniaSequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(),
6500000.0, true, false);
findNearbyLeishmaniaSequences(Point.builder().coordinates(LngLatAlt.builder().coordinates(0.0, 0.0).build()).build(),
6500000.0, true, true);
leishmaniaStats();
}
}, 30l, 3600l, TimeUnit.SECONDS); // repeat every 1 hour
LOGGER.info("Cache warmer initialized successfully");
}

@Override
public void close() throws IOException {
LOGGER.info("Cache warmer shutdown successfully");
}

}
Loading

0 comments on commit 0c69017

Please sign in to comment.