ref 22700: DataMiner - Check max computations limit
Updated max computations parameter check.
This commit is contained in:
parent
fbade3e930
commit
5f9681048f
|
@ -3,6 +3,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
# Changelog for "dataminer"
|
||||
|
||||
|
||||
## [v1.8.0-SNAPSHOT] - 2022-01-24
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fixed max computations support [#22700]
|
||||
|
||||
|
||||
## [v1.7.1] - 2021-05-24
|
||||
|
||||
### Fixes
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.dataanalysis</groupId>
|
||||
<artifactId>dataminer</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<version>1.8.0-SNAPSHOT</version>
|
||||
<name>dataminer</name>
|
||||
<description>An e-Infrastructure service providing state-of-the art DataMining algorithms and ecological modelling approaches under the Web Processing Service (WPS) standard.</description>
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm implements Observable, Cancellable {
|
||||
|
||||
private static final int COMPUTATION_WAIT_FOR_RUN_REQUEST = 20000;
|
||||
|
||||
/**
|
||||
* Deploying procedure: 1 - modify configuration files 2 - modify resource
|
||||
* file: resources/templates/setup.cfg 3 - generate classes with
|
||||
|
@ -85,30 +87,41 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
this.wpsExternalID = wpsExternalID;
|
||||
}
|
||||
|
||||
public static synchronized void addComputation(String session, String user) {
|
||||
private static synchronized void addComputation(String session, String user) {
|
||||
runningcomputations.put(session, user);
|
||||
}
|
||||
|
||||
public static synchronized void removeComputation(String session) {
|
||||
private static synchronized void removeComputation(String session) {
|
||||
runningcomputations.remove(session);
|
||||
}
|
||||
|
||||
public static synchronized int getRuningComputations() {
|
||||
private static synchronized int getRuningComputations() {
|
||||
return runningcomputations.size();
|
||||
}
|
||||
|
||||
public static synchronized String displayRunningComputations() {
|
||||
private static synchronized String displayRunningComputations() {
|
||||
return runningcomputations.toString();
|
||||
}
|
||||
|
||||
public void waitForResources() throws Exception {
|
||||
while (getRuningComputations() > ConfigurationManager.getMaxComputations()) {
|
||||
Thread.sleep(20000);
|
||||
private void waitForResources(String computationSession, String username, String scope) throws Exception {
|
||||
while (waitCondition(computationSession, username, scope)) {
|
||||
Thread.sleep(COMPUTATION_WAIT_FOR_RUN_REQUEST);
|
||||
LOGGER.debug("Waiting for resources to be available: " + displayRunningComputations());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static synchronized boolean waitCondition(String computationSession, String username, String scope) {
|
||||
if (getRuningComputations() >= ConfigurationManager.getMaxComputations()) {
|
||||
return true;
|
||||
} else {
|
||||
// add the computation to the global list of computations
|
||||
LOGGER.debug("Add computation to run: {}", computationSession);
|
||||
addComputation(computationSession, username + ":" + scope);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// inner objects
|
||||
public AlgorithmConfiguration config;
|
||||
public InfrastructureDialoguer infrastructureDialoguer;
|
||||
|
@ -366,11 +379,9 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
config = configManager.getConfig();
|
||||
LOGGER.info("Configured algorithm with session " + computationSession);
|
||||
time("Configuration");
|
||||
waitForResources();
|
||||
waitForResources(computationSession, configManager.getUsername(), configManager.getScope());
|
||||
LOGGER.info("Running algorithm with session " + computationSession);
|
||||
time("Waiting time for resources to be free");
|
||||
// add the computation to the global list of computations
|
||||
addComputation(computationSession, configManager.getUsername() + ":" + configManager.getScope());
|
||||
|
||||
String scope = configManager.getScope();
|
||||
String username = configManager.getUsername();
|
||||
|
@ -502,8 +513,8 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
|
|||
throw e;
|
||||
} finally {
|
||||
LOGGER.debug("accounting algorithm");
|
||||
if(operationResult==null){
|
||||
operationResult=OperationResult.FAILED;
|
||||
if (operationResult == null) {
|
||||
operationResult = OperationResult.FAILED;
|
||||
}
|
||||
accountAlgorithmExecution(startTimeLong, System.currentTimeMillis(), operationResult);
|
||||
LOGGER.debug("Deleting Input Tables");
|
||||
|
|
Loading…
Reference in New Issue