git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@179069 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0adfa5b959
commit
9d6794ffde
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue