max computation, saveOnStorage, simulationMode become init parameters of web.xml
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/wps@173382 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3929c94f04
commit
0c5874e9f1
|
@ -12,6 +12,20 @@
|
|||
<param-value>/home/gcube/wps_algorithms/algorithms</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>maxComputation</param-name>
|
||||
<param-value>4</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>saveOnStorage</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>simulationMode</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
|
||||
|
||||
<!-- security-constraint> <web-resource-collection> <web-resource-name>My
|
||||
JSP</web-resource-name> <url-pattern>/webAdmin/index.jsp</url-pattern> <http-method>GET</http-method>
|
||||
<http-method>POST</http-method> </web-resource-collection> <auth-constraint>
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.xmlbeans.XmlException;
|
|||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.apache.xmlbeans.XmlOptions;
|
||||
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.AbstractEcologicalEngineMapper;
|
||||
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.EnvironmentVariableManager;
|
||||
import org.n52.wps.commons.context.ExecutionContext;
|
||||
import org.n52.wps.commons.context.ExecutionContextFactory;
|
||||
import org.n52.wps.io.data.IComplexData;
|
||||
|
@ -70,6 +71,7 @@ public class ExecuteRequest extends Request implements IObserver {
|
|||
private ExecuteDocument execDom;
|
||||
private Map<String, IData> returnResults;
|
||||
private ExecuteResponseBuilder execRespType;
|
||||
private EnvironmentVariableManager env;
|
||||
|
||||
/**
|
||||
* Creates an ExecuteRequest based on a Document (HTTP_POST)
|
||||
|
@ -78,8 +80,9 @@ public class ExecuteRequest extends Request implements IObserver {
|
|||
* The clients submission
|
||||
* @throws ExceptionReport
|
||||
*/
|
||||
public ExecuteRequest(Document doc) throws ExceptionReport {
|
||||
public ExecuteRequest(Document doc, EnvironmentVariableManager env) throws ExceptionReport {
|
||||
super(doc);
|
||||
this.env = env;
|
||||
initWpsID();
|
||||
try {
|
||||
LOGGER.debug("Preparing the ExecuteRequest for POST");
|
||||
|
@ -113,8 +116,9 @@ public class ExecuteRequest extends Request implements IObserver {
|
|||
* treated as non case sensitive. @param ciMap The client input @throws
|
||||
* ExceptionReport
|
||||
*/
|
||||
public ExecuteRequest(CaseInsensitiveMap ciMap) throws ExceptionReport {
|
||||
public ExecuteRequest(CaseInsensitiveMap ciMap, EnvironmentVariableManager env) throws ExceptionReport {
|
||||
super(ciMap);
|
||||
this.env = env;
|
||||
initWpsID();
|
||||
initForGET(ciMap);
|
||||
// validate the client input
|
||||
|
@ -598,9 +602,12 @@ public class ExecuteRequest extends Request implements IObserver {
|
|||
}
|
||||
if (algorithm instanceof AbstractEcologicalEngineMapper) {
|
||||
((AbstractEcologicalEngineMapper) algorithm).setWpsExternalID(wpsid);
|
||||
((AbstractEcologicalEngineMapper) algorithm).setEnvironmentVariableManager(env);
|
||||
((AbstractEcologicalEngineMapper) algorithm).setObserver(GCubeObserver.getObserver());
|
||||
}
|
||||
|
||||
|
||||
//TODO: running algorithm
|
||||
if (algorithm instanceof AbstractTransactionalAlgorithm) {
|
||||
returnResults = ((AbstractTransactionalAlgorithm) algorithm).run(execDom);
|
||||
} else {
|
||||
|
|
|
@ -43,6 +43,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||
import org.apache.commons.collections.map.CaseInsensitiveMap;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.common.authorization.library.AuthorizedTasks;
|
||||
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.EnvironmentVariableManager;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.n52.wps.server.ExceptionReport;
|
||||
import org.n52.wps.server.WebProcessingService;
|
||||
|
@ -74,6 +75,8 @@ public class RequestHandler {
|
|||
|
||||
protected Request req;
|
||||
|
||||
private EnvironmentVariableManager env;
|
||||
|
||||
// Empty constructor due to classes which extend the RequestHandler
|
||||
protected RequestHandler() {
|
||||
|
||||
|
@ -90,10 +93,11 @@ public class RequestHandler {
|
|||
* @throws ExceptionReport
|
||||
* If the requested operation is not supported
|
||||
*/
|
||||
public RequestHandler(Map<String, String[]> params, OutputStream os)
|
||||
public RequestHandler(Map<String, String[]> params, OutputStream os, EnvironmentVariableManager env)
|
||||
throws ExceptionReport {
|
||||
this.os = os;
|
||||
this.params=params;
|
||||
this.env = env;
|
||||
//sleepingTime is 0, by default.
|
||||
/*if(WPSConfiguration.getInstance().exists(PROPERTY_NAME_COMPUTATION_TIMEOUT)) {
|
||||
this.sleepingTime = Integer.parseInt(WPSConfiguration.getInstance().getProperty(PROPERTY_NAME_COMPUTATION_TIMEOUT));
|
||||
|
@ -138,7 +142,7 @@ public class RequestHandler {
|
|||
InnerMethodName.instance.set("DescribeProcess");
|
||||
}
|
||||
else if (requestType.equalsIgnoreCase("Execute")) {
|
||||
req = new ExecuteRequest(ciMap);
|
||||
req = new ExecuteRequest(ciMap, env);
|
||||
setResponseMimeType((ExecuteRequest)req);
|
||||
InnerMethodName.instance.set("Execute");
|
||||
}
|
||||
|
@ -259,7 +263,7 @@ public class RequestHandler {
|
|||
// get the request type
|
||||
if (nodeURI.equals(WebProcessingService.WPS_NAMESPACE) && localName.equals("Execute")) {
|
||||
LOGGER.debug("Detected Request to Execute!");
|
||||
req = new ExecuteRequest(doc);
|
||||
req = new ExecuteRequest(doc, env);
|
||||
setResponseMimeType((ExecuteRequest)req);
|
||||
InnerMethodName.instance.set("Execute");
|
||||
LOGGER.debug("Request to Execute Configured!");
|
||||
|
|
|
@ -50,6 +50,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.xmlbeans.XmlException;
|
||||
import org.gcube.data.analysis.wps.repository.AlgorithmUpdater;
|
||||
import org.gcube.data.analysis.wps.repository.GcubeAlgorithmRepository;
|
||||
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping.EnvironmentVariableManager;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
import org.n52.wps.GeneratorDocument.Generator;
|
||||
|
@ -85,9 +86,12 @@ public class WebProcessingService extends HttpServlet {
|
|||
|
||||
private static final String DIRECTORY_PARAM = "algorithmDirectory";
|
||||
|
||||
private static final String MAX_COMPUTATION_PARAM = "maxComputation";
|
||||
private static final String SAVEONSTORAGE_PARAM = "saveOnStorage";
|
||||
private static final String SIMULATION_MODE_PARAM = "simulationMode";
|
||||
|
||||
private ApplicationContext context = ContextProvider.get();
|
||||
|
||||
|
||||
private EnvironmentVariableManager env ;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -95,6 +99,12 @@ public class WebProcessingService extends HttpServlet {
|
|||
LOGGER.info("initialising WPS");
|
||||
String dir = (String)context.application().getInitParameter(DIRECTORY_PARAM);
|
||||
GcubeAlgorithmRepository.setUpdater(new AlgorithmUpdater(dir));
|
||||
|
||||
int maxComp = Integer.parseInt(context.application().getInitParameter(MAX_COMPUTATION_PARAM));
|
||||
boolean saveOnStorage = Boolean.parseBoolean(context.application().getInitParameter(SAVEONSTORAGE_PARAM));
|
||||
boolean simulationMode = Boolean.parseBoolean(context.application().getInitParameter(SIMULATION_MODE_PARAM));
|
||||
|
||||
env = new EnvironmentVariableManager(maxComp, saveOnStorage, simulationMode);
|
||||
LOGGER.info("WPS initialised");
|
||||
}
|
||||
|
||||
|
@ -277,7 +287,7 @@ public class WebProcessingService extends HttpServlet {
|
|||
OutputStream out = res.getOutputStream(); // closed by res.flushBuffer();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
RequestHandler handler = new RequestHandler((Map<String, String[]>) req.getParameterMap(), out);
|
||||
RequestHandler handler = new RequestHandler((Map<String, String[]>) req.getParameterMap(), out, env);
|
||||
String mimeType = handler.getResponseMimeType();
|
||||
res.setContentType(mimeType);
|
||||
handler.handle();
|
||||
|
|
|
@ -25,7 +25,7 @@ no. 654119), SoBigData (grant no. 654024), AGINFRA PLUS (grant no. 731001).
|
|||
Version
|
||||
--------------------------------------------------
|
||||
|
||||
1.1.1-SNAPSHOT (2018-06-14)
|
||||
1.1.1-SNAPSHOT (2018-10-12)
|
||||
|
||||
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||
|
||||
|
|
|
@ -12,6 +12,20 @@
|
|||
<param-value>/home/gcube/wps_algorithms/algorithms</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>maxComputation</param-name>
|
||||
<param-value>4</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>saveOnStorage</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>simulationMode</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
|
||||
|
||||
<!-- security-constraint> <web-resource-collection> <web-resource-name>My
|
||||
JSP</web-resource-name> <url-pattern>/webAdmin/index.jsp</url-pattern> <http-method>GET</http-method>
|
||||
<http-method>POST</http-method> </web-resource-collection> <auth-constraint>
|
||||
|
|
Loading…
Reference in New Issue