git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@131699 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a1cb85737b
commit
3f5287800f
|
@ -238,7 +238,10 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
for (File file : generatedFiles) {
|
for (File file : generatedFiles) {
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
AnalysisLogger.getLogger().debug("Deleting File " + file.getAbsolutePath());
|
AnalysisLogger.getLogger().debug("Deleting File " + file.getAbsolutePath());
|
||||||
try{AnalysisLogger.getLogger().debug("Deleting File Check " + file.delete());}catch(Exception e){}
|
try {
|
||||||
|
AnalysisLogger.getLogger().debug("Deleting File Check " + file.delete());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
AnalysisLogger.getLogger().debug("Deleting File - File does not exist " + file.getAbsolutePath());
|
AnalysisLogger.getLogger().debug("Deleting File - File does not exist " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
@ -249,19 +252,23 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
public void manageUserToken() {
|
public void manageUserToken() {
|
||||||
String scope = null;
|
String scope = null;
|
||||||
String username = null;
|
String username = null;
|
||||||
|
String token = null;
|
||||||
// DONE get scope and username from SmartGears
|
// DONE get scope and username from SmartGears
|
||||||
// get scope from SmartGears
|
// get scope from SmartGears
|
||||||
TokenManager tokenm = new TokenManager();
|
TokenManager tokenm = new TokenManager();
|
||||||
tokenm.getCredentials();
|
tokenm.getCredentials();
|
||||||
scope = tokenm.getScope();
|
scope = tokenm.getScope();
|
||||||
username = tokenm.getUserName();
|
username = tokenm.getUserName();
|
||||||
|
token = tokenm.getToken();
|
||||||
// set parameters
|
// set parameters
|
||||||
inputs.put(ConfigurationManager.scopeParameter, scope);
|
inputs.put(ConfigurationManager.scopeParameter, scope);
|
||||||
inputs.put(ConfigurationManager.usernameParameter, username);
|
inputs.put(ConfigurationManager.usernameParameter, username);
|
||||||
|
inputs.put(ConfigurationManager.tokenParameter, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
long statusInterrupt = 0;
|
long statusInterrupt = 0;
|
||||||
float previousStatus = -3;
|
float previousStatus = -3;
|
||||||
|
|
||||||
public void updateStatus(float status) {
|
public void updateStatus(float status) {
|
||||||
if (agent != null) {
|
if (agent != null) {
|
||||||
long stream = 0;
|
long stream = 0;
|
||||||
|
@ -278,21 +285,31 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
agent = null;
|
agent = null;
|
||||||
status = -1f;
|
status = -1f;
|
||||||
super.update(new Integer((int) status));
|
super.update(new Integer((int) status));
|
||||||
|
try {
|
||||||
updateComputationOnWS(status, null);
|
updateComputationOnWS(status, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
if (status != previousStatus) {
|
if (status != previousStatus) {
|
||||||
AnalysisLogger.getLogger().debug("STATUS update to:" + status + " - status interrupt " + statusInterrupt);
|
AnalysisLogger.getLogger().debug("STATUS update to:" + status + " - status interrupt " + statusInterrupt);
|
||||||
previousStatus = status;
|
previousStatus = status;
|
||||||
super.update(new Integer((int) status));
|
super.update(new Integer((int) status));
|
||||||
|
try {
|
||||||
updateComputationOnWS(status, null);
|
updateComputationOnWS(status, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
AnalysisLogger.getLogger().debug("WARNING: STATUS RETRIEVAL EXCEPTION "+e.getLocalizedMessage());
|
AnalysisLogger.getLogger().debug("WARNING - STATUS RETRIEVAL EXCEPTION " + e.getLocalizedMessage());
|
||||||
|
AnalysisLogger.getLogger().debug(e);
|
||||||
// stream = statusInterrupt;
|
// stream = statusInterrupt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateComputationOnWS(float status, String exception) {
|
public void updateComputationOnWS(float status, String exception) {
|
||||||
updateComputationOnWS(status, exception, null, null);
|
updateComputationOnWS(status, exception, null, null);
|
||||||
}
|
}
|
||||||
|
@ -409,8 +426,9 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
// run the computation
|
// run the computation
|
||||||
AnalysisLogger.getLogger().info("9 - Running the computation and updater");
|
AnalysisLogger.getLogger().info("9 - Running the computation and updater");
|
||||||
|
|
||||||
AnalysisLogger.getLogger().info("Initializing the computation");
|
AnalysisLogger.getLogger().info("Initializing the WPS status of the computation");
|
||||||
updateStatus(0);
|
updateStatus(0);
|
||||||
|
AnalysisLogger.getLogger().info("Initializing the computation");
|
||||||
agent.init();
|
agent.init();
|
||||||
AnalysisLogger.getLogger().info("Updating status");
|
AnalysisLogger.getLogger().info("Updating status");
|
||||||
runStatusUpdater();
|
runStatusUpdater();
|
||||||
|
@ -542,7 +560,6 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void cleanResources() {
|
private void cleanResources() {
|
||||||
times = null;
|
times = null;
|
||||||
agent = null;
|
agent = null;
|
||||||
|
@ -575,19 +592,12 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> command(final String cmdline, final String directory) {
|
||||||
public static List<String> command(final String cmdline,
|
|
||||||
final String directory) {
|
|
||||||
try {
|
try {
|
||||||
Process process =
|
Process process = new ProcessBuilder(new String[] { "bash", "-c", cmdline }).redirectErrorStream(true).directory(new File(directory)).start();
|
||||||
new ProcessBuilder(new String[] {"bash", "-c", cmdline})
|
|
||||||
.redirectErrorStream(true)
|
|
||||||
.directory(new File(directory))
|
|
||||||
.start();
|
|
||||||
|
|
||||||
List<String> output = new ArrayList<String>();
|
List<String> output = new ArrayList<String>();
|
||||||
BufferedReader br = new BufferedReader(
|
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
new InputStreamReader(process.getInputStream()));
|
|
||||||
String line = null;
|
String line = null;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
output.add(line);
|
output.add(line);
|
||||||
|
@ -603,5 +613,4 @@ public class AbstractEcologicalEngineMapper extends AbstractAnnotatedAlgorithm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue