прогресс пакетов сапфор

This commit is contained in:
2024-02-16 23:49:04 +03:00
parent 0efd6ebb9b
commit cd2fefd099
3 changed files with 34 additions and 21 deletions

View File

@@ -1,7 +1,9 @@
package TestingSystem.Common.ThreadsPlanner;
import Common.Global;
import Common.Utils.InterruptThread;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.Vector;
public abstract class ThreadsPlanner {
@@ -20,6 +22,8 @@ public abstract class ThreadsPlanner {
//---
protected int threadMaxId = 0;
protected int wait_ms;
protected int done_threads = 0;
protected int progress = 0;
protected LinkedHashMap<Integer, Thread> threads = new LinkedHashMap<>();
protected Vector<Integer> activeThreads = new Vector<>();
protected Vector<Integer> waitingThreads = new Vector<>();
@@ -74,10 +78,20 @@ public abstract class ThreadsPlanner {
if (!thread.isAlive()) {
toExclude.add(i);
kernels++;
done_threads++;
}
}
activeThreads.removeAll(toExclude);
//--
double progress = ((double)done_threads/threads.size())*100.0;
Global.Log.Print("done_threads="+done_threads+";all_threads="+threads.size()+";progress="+progress);
File progress_file = new File("progress");
try {
FileUtils.writeStringToFile(progress_file, String.valueOf(((int)progress)));
}
catch (Exception exception){
exception.printStackTrace();
}
}
protected void tryStartThreads() throws Exception {
Vector<Integer> toExclude = new Vector<>();

View File

@@ -84,17 +84,32 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
}
@Override
protected boolean CheckNextState() throws Exception {
boolean progress_changed = false;
boolean state_changed = false;
//--
File workspace = testingPackage.getLocalWorkspace();
//--
File progress = new File(workspace, "progress");
if (progress.exists()) {
String s = FileUtils.readFileToString(progress);
int current_progress = Integer.parseInt(s);
if (current_progress != testingPackage.progress) {
Print("progress changed: " + current_progress);
testingPackage.progress = current_progress;
progress_changed = true;
}
}
//--
File done = new File(workspace, Constants.DONE);
File aborted = new File(workspace, Constants.ABORTED);
if (done.exists()) {
testingPackage.state = TasksPackageState.Analysis;
return true;
state_changed = true;
} else if (aborted.exists()) {
testingPackage.state = TasksPackageState.Aborted;
return true;
state_changed = true;
}
return false;
return progress_changed || state_changed;
}
@Override
protected void DownloadResults() throws Exception {