git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineSmartExecutor@154440 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c5e12d5439
commit
df9a34cff0
9
pom.xml
9
pom.xml
|
@ -75,6 +75,15 @@
|
|||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.gcube.common.resources.gcore.GCoreEndpoint;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.impl.XQuery;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -32,16 +34,27 @@ public abstract class StandardLocalInfraAlgorithm extends StandardLocalExternalA
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean sendMessage(String token, String email, String subject, String body) throws Exception {
|
||||
|
||||
String socialServiceEnpoint = retrieveSocialServiceEnpoint();
|
||||
|
||||
LOGGER.debug("contacting social service endpoint {}",socialServiceEnpoint+SEND_MESSAGE_METHOD+"?gcube-token="+token);
|
||||
|
||||
PostMethod putMessage = new PostMethod(socialServiceEnpoint+SEND_MESSAGE_METHOD+"?gcube-token="+token);
|
||||
String jsonRequest = String.format("{\"subject\":\"%s\", \"body\":\"%s\", \"recipients\":[\"%s\"]}",subject,body, email);
|
||||
|
||||
putMessage.setRequestEntity(new StringRequestEntity(jsonRequest, "application/json" , "UTF-8"));
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("subject", subject);
|
||||
obj.put("body", body);
|
||||
JSONArray list = new JSONArray();
|
||||
list.add(email);
|
||||
obj.put("recipients", list);
|
||||
|
||||
LOGGER.debug("json request is {}", jsonRequest);
|
||||
//String jsonRequest = String.format("{\"subject\":\"%s\", \"body\":\"%s\", \"recipients\":[{\"id\":\"%s\"}]}",subject,body, email);
|
||||
|
||||
putMessage.setRequestEntity(new StringRequestEntity(obj.toJSONString(), "application/json" , "UTF-8"));
|
||||
|
||||
LOGGER.debug("json request is {}", obj.toJSONString());
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
||||
|
|
|
@ -13,16 +13,17 @@ import java.net.URLEncoder;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
|
||||
import org.gcube.dataanalysis.ecoengine.interfaces.ActorNode;
|
||||
import org.gcube.dataanalysis.ecoengine.interfaces.StandardLocalInfraAlgorithm;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GenericWorker extends StandardLocalInfraAlgorithm{
|
||||
|
||||
private static String genericWorkerDir = "/genericworker/";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GenericWorker.class);
|
||||
|
||||
public static String AlgorithmClassParameter = "AlgorithmClass";
|
||||
public static String RightSetStartIndexParameter = "RightSetStartIndex";
|
||||
|
@ -61,7 +62,6 @@ public class GenericWorker extends StandardLocalInfraAlgorithm{
|
|||
PrintStream origOut = System.out;
|
||||
PrintStream origErr = System.err;
|
||||
status = 0f;
|
||||
Logger logger = AnalysisLogger.getLogger();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
File tempDir = null ;
|
||||
try {
|
||||
|
@ -137,8 +137,7 @@ public class GenericWorker extends StandardLocalInfraAlgorithm{
|
|||
} catch (Throwable e) {
|
||||
outputParameters.put(OutputParameter, TASK_FAILURE);
|
||||
outputParameters.put("Log", e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
logger.debug("GenericWorker-> ERROR: " + e.getLocalizedMessage());
|
||||
logger.error("GenericWorker-> ERROR: " ,e);
|
||||
status = 100f;
|
||||
throw new Exception(e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -163,8 +162,7 @@ public class GenericWorker extends StandardLocalInfraAlgorithm{
|
|||
nodeConfigurationFileObject.delete();
|
||||
|
||||
}catch(Exception e3){
|
||||
e3.printStackTrace();
|
||||
logger.debug("GenericWorker-> Error deleting files");
|
||||
logger.warn("GenericWorker-> Error deleting files",e3);
|
||||
}
|
||||
status = 100f;
|
||||
}
|
||||
|
@ -183,7 +181,7 @@ public class GenericWorker extends StandardLocalInfraAlgorithm{
|
|||
|
||||
@Override
|
||||
protected void process() throws Exception {
|
||||
AnalysisLogger.getLogger().debug("Parameters: "+config.getGeneralProperties());
|
||||
logger.debug("Parameters: "+config.getGeneralProperties());
|
||||
|
||||
String algorithmClass = config.getParam(AlgorithmClassParameter);
|
||||
|
||||
|
@ -196,9 +194,9 @@ public class GenericWorker extends StandardLocalInfraAlgorithm{
|
|||
File nodeConfigurationFileObject=new File (config.getParam(ConfigurationFileParameter));
|
||||
boolean deleteFiles= Boolean.parseBoolean(config.getParam(DeleteTemporaryFilesParameter));
|
||||
|
||||
AnalysisLogger.getLogger().debug("Executing the algorithm");
|
||||
logger.debug("Executing the algorithm");
|
||||
executeAlgorithm(algorithmClass, rightStartIndex, numberOfRightElementsToProcess, leftStartIndex, numberOfLeftElementsToProcess, isduplicate, session, nodeConfigurationFileObject, deleteFiles);
|
||||
AnalysisLogger.getLogger().debug("Algorithm executed!");
|
||||
logger.debug("Algorithm executed!");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ package org.gcube.dataanalysis.executor.nodes.transducers;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.ALG_PROPS;
|
||||
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
|
||||
import org.gcube.dataanalysis.ecoengine.datatypes.StatisticalType;
|
||||
|
@ -12,9 +10,13 @@ import org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsMerger;
|
|||
import org.gcube.dataanalysis.ecoengine.utils.Transformations;
|
||||
import org.gcube.dataanalysis.executor.generators.D4ScienceDistributedProcessing;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OccurrenceMergingNode extends ActorNode {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OccurrenceMergingNode.class);
|
||||
|
||||
// variables
|
||||
protected AlgorithmConfiguration currentconfig;
|
||||
protected SessionFactory dbHibConnection;
|
||||
|
@ -69,12 +71,14 @@ public class OccurrenceMergingNode extends ActorNode {
|
|||
|
||||
try{
|
||||
status = 0;
|
||||
AlgorithmConfiguration config = Transformations.restoreConfig(new File(sandboxFolder,nodeConfigurationFileObject).getAbsolutePath());
|
||||
String configFileAbsolutePath = new File(sandboxFolder,nodeConfigurationFileObject).getAbsolutePath();
|
||||
logger.debug("config file absolute path is {}", configFileAbsolutePath);
|
||||
AlgorithmConfiguration config = Transformations.restoreConfig(configFileAbsolutePath);
|
||||
config.setConfigPath(sandboxFolder);
|
||||
processor.setConfiguration(config);
|
||||
AnalysisLogger.getLogger().info("Initializing variables");
|
||||
logger.info("Initializing variables");
|
||||
processor.init();
|
||||
AnalysisLogger.getLogger().info("Initializing DB");
|
||||
logger.info("Initializing DB");
|
||||
processor.initDB(false);
|
||||
status = 0.5f;
|
||||
processor.takeRange(leftStartIndex, numberOfLeftElementsToProcess, rightStarIndex, numberOfRightElementsToProcess);
|
||||
|
@ -123,7 +127,7 @@ public class OccurrenceMergingNode extends ActorNode {
|
|||
try {
|
||||
processor.postProcess();
|
||||
} catch (Exception e) {
|
||||
AnalysisLogger.getLogger().info("Postprocessing Inapplicable");
|
||||
logger.info("Postprocessing Inapplicable");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue