From 93052ae38453901f8190607d12c84c9d5affc053 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Thu, 25 Jun 2020 16:16:02 +0200 Subject: [PATCH 1/2] WIP: set the connect & request timeout for BindingProvider service implementation --- .../dhp/utils/ISLookupClientFactory.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java b/dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java index 97fe4b9d8..9552eb2b3 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java @@ -1,15 +1,22 @@ package eu.dnetlib.dhp.utils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.util.Map; + +import javax.xml.ws.BindingProvider; + import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; public class ISLookupClientFactory { - private static final Log log = LogFactory.getLog(ISLookupClientFactory.class); + private static final Logger log = LoggerFactory.getLogger(ISLookupClientFactory.class); + + private static int requestTimeout = 60000 * 10; + private static int connectTimeout = 60000 * 10; public static ISLookUpService getLookUpService(final String isLookupUrl) { return getServiceStub(ISLookUpService.class, isLookupUrl); @@ -21,6 +28,25 @@ public class ISLookupClientFactory { final JaxWsProxyFactoryBean jaxWsProxyFactory = new JaxWsProxyFactoryBean(); jaxWsProxyFactory.setServiceClass(clazz); jaxWsProxyFactory.setAddress(endpoint); - return (T) jaxWsProxyFactory.create(); + + final T service = (T) jaxWsProxyFactory.create(); + + if (service instanceof BindingProvider) { + log + .info( + "setting timeouts for {} to requestTimeout: {}, connectTimeout: {}", + BindingProvider.class.getName(), requestTimeout, connectTimeout); + + Map requestContext = ((BindingProvider) service).getRequestContext(); + + requestContext.put("com.sun.xml.internal.ws.request.timeout", requestTimeout); + requestContext.put("com.sun.xml.internal.ws.connect.timeout", connectTimeout); + requestContext.put("com.sun.xml.ws.request.timeout", requestTimeout); + requestContext.put("com.sun.xml.ws.connect.timeout", connectTimeout); + requestContext.put("javax.xml.ws.client.receiveTimeout", requestTimeout); + requestContext.put("javax.xml.ws.client.connectionTimeout", connectTimeout); + } + + return service; } } From 35e6e9c064b1c4318a59576352d20fdebc39102d Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 28 Jul 2020 12:02:15 +0200 Subject: [PATCH 2/2] tests --- .../broker/oa/partial/oozie_app/workflow.xml | 54 +------------ .../dnetlib/dhp/oa/graph/raw/MappersTest.java | 16 +++- .../dhp/oa/graph/raw/odf_dataset_2.xml | 75 +++++++++++++++++++ 3 files changed, 90 insertions(+), 55 deletions(-) create mode 100644 dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/odf_dataset_2.xml diff --git a/dhp-workflows/dhp-broker-events/src/main/resources/eu/dnetlib/dhp/broker/oa/partial/oozie_app/workflow.xml b/dhp-workflows/dhp-broker-events/src/main/resources/eu/dnetlib/dhp/broker/oa/partial/oozie_app/workflow.xml index 80505ca1e..3c43c0b1b 100644 --- a/dhp-workflows/dhp-broker-events/src/main/resources/eu/dnetlib/dhp/broker/oa/partial/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-broker-events/src/main/resources/eu/dnetlib/dhp/broker/oa/partial/oozie_app/workflow.xml @@ -64,37 +64,11 @@ - + Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}] - - - - yarn - cluster - GenerateEventsJob - eu.dnetlib.dhp.broker.oa.GenerateEventsJob - dhp-broker-events-${projectVersion}.jar - - --executor-cores=${sparkExecutorCores} - --executor-memory=${sparkExecutorMemory} - --driver-memory=${sparkDriverMemory} - --conf spark.extraListeners=${spark2ExtraListeners} - --conf spark.sql.queryExecutionListeners=${spark2SqlQueryExecutionListeners} - --conf spark.yarn.historyServer.address=${spark2YarnHistoryServerAddress} - --conf spark.eventLog.dir=${nameNode}${spark2EventLogDir} - --conf spark.sql.shuffle.partitions=3840 - - --workingPath${workingPath} - --datasourceIdWhitelist${datasourceIdWhitelist} - --datasourceTypeWhitelist${datasourceTypeWhitelist} - --datasourceIdBlacklist${datasourceIdBlacklist} - - - - @@ -117,34 +91,10 @@ --index${esIndexName} --esHost${esIndexHost} - - - - - - - yarn - cluster - GenerateStatsJob - eu.dnetlib.dhp.broker.oa.GenerateStatsJob - dhp-broker-events-${projectVersion}.jar - - --executor-cores=${sparkExecutorCores} - --executor-memory=${sparkExecutorMemory} - --driver-memory=${sparkDriverMemory} - --conf spark.extraListeners=${spark2ExtraListeners} - --conf spark.sql.queryExecutionListeners=${spark2SqlQueryExecutionListeners} - --conf spark.yarn.historyServer.address=${spark2YarnHistoryServerAddress} - --conf spark.eventLog.dir=${nameNode}${spark2EventLogDir} - --conf spark.sql.shuffle.partitions=3840 - - --graphPath${graphInputPath} - --workingPath${workingPath} - - + \ No newline at end of file diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java index b157f7ec6..dcb4c49b4 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java @@ -5,9 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.when; import java.io.IOException; import java.util.List; @@ -21,8 +19,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import com.fasterxml.jackson.databind.ObjectMapper; + import eu.dnetlib.dhp.oa.graph.clean.CleaningFunctionTest; -import eu.dnetlib.dhp.oa.graph.raw.common.OafMapperUtils; import eu.dnetlib.dhp.oa.graph.raw.common.VocabularyGroup; import eu.dnetlib.dhp.schema.common.ModelConstants; import eu.dnetlib.dhp.schema.oaf.Author; @@ -266,6 +265,17 @@ public class MappersTest { assertTrue(s.getInstance().size() > 0); } + // @Test + void testDataset_2() throws IOException { + final String xml = IOUtils.toString(getClass().getResourceAsStream("odf_dataset_2.xml")); + + final List list = new OdfToOafMapper(vocs, false).processMdRecord(xml); + + System.out.println("***************"); + System.out.println(new ObjectMapper().writeValueAsString(list)); + System.out.println("***************"); + } + private void assertValidId(final String id) { assertEquals(49, id.length()); assertEquals('|', id.charAt(2)); diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/odf_dataset_2.xml b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/odf_dataset_2.xml new file mode 100644 index 000000000..17a87bcb7 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/odf_dataset_2.xml @@ -0,0 +1,75 @@ + + + + opentrials__::0000bf8e63d3d7e6b88421eabafae3f6 + feabb67c-1fd1-423b-aec6-606d04ce53c6 + 2019-03-27T15:15:22.22Z + opentrials__ + 2019-04-17T16:04:20.586Z + + + + https://clinicaltrials.gov/ct2/show/NCT02321059 + + http://apps.who.int/trialsearch/Trial3.aspx?trialid=NCT02321059 + NCT02321059 + + + + Jensen, Kristian K + + + + Validation of the Goodstrength System for Assessment of Abdominal Wall Strength in Patients With Incisional Hernia + + nct + + Denmark + + 0037 + + Patients with an incisional hernia in the midline and controls with an intact abdominal wall are examined twice with one week apart, in order to establish the test-retest reliability and internal and external validity of the Goodstrength trunk dynamometer. + + + OPEN + 0037 + 2014-11-11 + + + + + false + false + 0.9 + + + + + + + + + file:///var/lib/dnet/data/opentrials/opentrials.csv + + + + + + + false + false + 0.9 + + + + + \ No newline at end of file