Разделение очереди на разные машины, и исправление бага. могло выполняться более одного пакета одновременно
This commit is contained in:
@@ -11,6 +11,7 @@ import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import java.io.FileWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
protected P testingPackage;
|
||||
protected int getSleepMillis() {
|
||||
@@ -83,7 +84,7 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
}
|
||||
}
|
||||
//---
|
||||
protected abstract ServerCode getActivePackageCode();
|
||||
protected abstract ServerCode getActivePackagesCode();
|
||||
protected abstract ServerCode getCheckIfNeedsKillCode();
|
||||
protected abstract TasksPackageState getStateAfterStart();
|
||||
protected void InitSessionCredentials() {
|
||||
@@ -130,44 +131,49 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
}
|
||||
}
|
||||
// ---
|
||||
protected void PerformPackage(TestingPackage package_in) throws Exception{
|
||||
testingPackage = (P) package_in;
|
||||
//--
|
||||
Print(testingPackage.id + ":" + testingPackage.state.getDescription());
|
||||
//--
|
||||
InitSessionCredentials();
|
||||
if (testingPackage.state.equals(TasksPackageState.Analysis)) {
|
||||
AnalyseResults();
|
||||
UpdatePackageState(TasksPackageState.Done);
|
||||
} else {
|
||||
try {
|
||||
if (Connect()) {
|
||||
int ptk_id = (int) ServerCommand(getCheckIfNeedsKillCode(), testingPackage.id);
|
||||
if (ptk_id != Constants.Nan) {
|
||||
Print("package " + testingPackage.id + " NEEDS TO KILL");
|
||||
Kill();
|
||||
UpdatePackageState(TasksPackageState.Aborted);
|
||||
ServerCommand(ServerCode.DeleteObjectByPK, ptk_id);
|
||||
} else {
|
||||
Session();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Print("Ошибка сеанса. Соединение будет разорвано.");
|
||||
Print(ex.getMessage());
|
||||
Disconnect();
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
//--
|
||||
testingPackage.destructor();
|
||||
testingPackage = null;
|
||||
System.gc();
|
||||
//--
|
||||
|
||||
}
|
||||
public void Perform() {
|
||||
try {
|
||||
testingPackage = null;
|
||||
testingPackage = (P) ServerCommand(getActivePackageCode());
|
||||
if (testingPackage != null) {
|
||||
Print(testingPackage.id + ":" + testingPackage.state.getDescription());
|
||||
//--
|
||||
InitSessionCredentials();
|
||||
if (testingPackage.state.equals(TasksPackageState.Analysis)) {
|
||||
AnalyseResults();
|
||||
UpdatePackageState(TasksPackageState.Done);
|
||||
} else {
|
||||
try {
|
||||
if (Connect()) {
|
||||
int ptk_id = (int) ServerCommand(getCheckIfNeedsKillCode(), testingPackage.id);
|
||||
if (ptk_id != Constants.Nan) {
|
||||
Print("package " + testingPackage.id + " NEEDS TO KILL");
|
||||
Kill();
|
||||
UpdatePackageState(TasksPackageState.Aborted);
|
||||
ServerCommand(ServerCode.DeleteObjectByPK, ptk_id);
|
||||
} else {
|
||||
Session();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Print("Ошибка сеанса. Соединение будет разорвано.");
|
||||
Print(ex.getMessage());
|
||||
Disconnect();
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
//--
|
||||
testingPackage.destructor();
|
||||
testingPackage = null;
|
||||
System.gc();
|
||||
//--
|
||||
}
|
||||
//else Print(this.getClass().getSimpleName()+": no active package found");
|
||||
Vector<P> activePackages = (Vector<P>) ServerCommand(getActivePackagesCode());
|
||||
// System.out.println(this.getClass().getSimpleName()+": found "+activePackages.size()+" active packages"); //Тесты:
|
||||
for (P activePackage: activePackages)
|
||||
PerformPackage(activePackage);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user