This commit is contained in:
Lucio Lelii 2019-04-17 15:36:38 +00:00
parent 0adfa5b959
commit 9d6794ffde
3 changed files with 28 additions and 14 deletions

View File

@ -248,14 +248,14 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
float previousStatus = -3;
String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname();
public void updateStatus(float status) {
public void updateStatus(float status, boolean canWrite) {
if (agent != null) {
if (status != previousStatus) {
LOGGER.debug("STATUS update to: {} ", status );
previousStatus = status;
super.update(new Integer((int) status));
try {
updateComputationOnWS(status, null);
if (canWrite) updateComputationOnWS(status, null);
} catch (Exception e) {
LOGGER.warn("error updating compution on WS");
}
@ -425,11 +425,11 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
LOGGER.info("9 - Running the computation and updater");
LOGGER.info("Initializing the WPS status of the computation");
updateStatus(0);
updateStatus(0, canWriteOnShub);
LOGGER.info("Initializing the computation");
agent.init();
LOGGER.info("Updating status");
runStatusUpdater();
runStatusUpdater(canWriteOnShub);
LOGGER.info("Running the computation");
agent.compute();
LOGGER.info("The computation has finished. Retrieving output");
@ -505,8 +505,12 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
private boolean checkWriteAuthorization(String username) {
if (env!=null && env.getShubUsersExcluded()!=null) {
if (env.getShubUsersExcluded().isEmpty()) return false;
else if (env.getShubUsersExcluded().contains(username)) return false;
if (env.getShubUsersExcluded().isEmpty()) {
return false;
}
if (env.getShubUsersExcluded().contains(username)) {
return false;
}
}
return true;
}
@ -534,11 +538,17 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
public class StatusUpdater implements Runnable {
private boolean canWrite = true;
public StatusUpdater(boolean canWrite) {
this.canWrite = canWrite;
}
@Override
public void run() {
while (agent != null && !isCancelled() && agent.getStatus() < 100) {
try {
updateStatus(agent.getStatus());
updateStatus(agent.getStatus(), canWrite);
Thread.sleep(10000);
} catch (InterruptedException e) {}
}
@ -546,8 +556,8 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm i
}
}
private void runStatusUpdater() {
StatusUpdater updater = new StatusUpdater();
private void runStatusUpdater(boolean canWrite) {
StatusUpdater updater = new StatusUpdater(canWrite);
Thread t = new Thread(updater);
t.start();

View File

@ -29,6 +29,8 @@ public class ConfigurationManager {
private static Boolean useStorage = null;
static boolean simulationMode = false;
EnvironmentVariableManager env = null;
public static synchronized Integer getMaxComputations(){
return maxComputations;
}
@ -78,10 +80,11 @@ public class ConfigurationManager {
public ConfigurationManager(EnvironmentVariableManager env) {
if (env == null) inizializePropertiesUsingTemplateFile();
}
public ConfigurationManager() {
inizializePropertiesUsingTemplateFile();
else {
maxComputations = env.getMaxComputation();
useStorage = env.isSaveOnStorage();
simulationMode = env.isSimulationMode();
}
}
public AlgorithmConfiguration getConfig() {

View File

@ -9,6 +9,7 @@ public class EnvironmentVariableManager {
this.maxComputation = maxComputation;
this.saveOnStorage = saveOnStorage;
this.simulationMode = simulationMode;
this.shubUsersExcluded = shubUsersExcluded;
}
private int maxComputation;
private boolean saveOnStorage;