Лимит ошибок связи 10
This commit is contained in:
2024-04-08 01:30:46 +03:00
parent 09afe82704
commit 4e503d3b9b
8 changed files with 56 additions and 24 deletions

View File

@@ -62,7 +62,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override
public void GetVersionInfo() {
version = 1091;
version = 1092;
String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime());

View File

@@ -28,12 +28,15 @@ public enum TasksPackageState implements StatusEnum {
Analysis,
//-
Done,
Aborted;
Aborted,
ConnectionError
;
public boolean isActive() {
switch (this) {
case Done:
case Aborted:
case Draft:
case ConnectionError:
return false;
default:
return true;
@@ -88,6 +91,8 @@ public enum TasksPackageState implements StatusEnum {
return "анализ результатов";
case Done:
return "завершен";
case ConnectionError:
return "Сбой связи";
default:
return StatusEnum.super.getDescription();
}

View File

@@ -20,6 +20,8 @@ public abstract class TestingPackage<J> extends riDBObject {
public int progress = 0; //прогресс выполнения
public long StartDate = 0;
public long ChangeDate = 0;
@Description("DEFAULT 0")
public int connectionErrosCount = 0;
public TasksPackageState state = TasksPackageState.Draft;
//--
@Override
@@ -36,6 +38,7 @@ public abstract class TestingPackage<J> extends riDBObject {
progress = tp.progress;
StartDate = tp.StartDate;
ChangeDate = tp.ChangeDate;
connectionErrosCount = tp.connectionErrosCount;
state = tp.state;
}
public TestingPackage(TestingPackage p) {

View File

@@ -138,28 +138,40 @@ public abstract class TestingPlanner<P extends TestingPackage> {
//--
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, new Pair(TestingPackageToKill.class, ptk_id));
if (testingPackage.connectionErrosCount>=10){
Print(testingPackage.id+" had 10 connection errors. stop");
UpdatePackageState(TasksPackageState.ConnectionError);
}else {
//--
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, new Pair(TestingPackageToKill.class, ptk_id));
} else {
Session();
}
} else {
Session();
testingPackage.connectionErrosCount++;
UpdatePackage();
}
} catch (Exception ex) {
Print("Ошибка сеанса. Соединение будет разорвано.");
Print(ex.getMessage());
Disconnect();
//
testingPackage.connectionErrosCount++;
UpdatePackage();
} finally {
}
} catch (Exception ex) {
Print("Ошибка сеанса. Соединение будет разорвано.");
Print(ex.getMessage());
Disconnect();
} finally {
}
}
//--

View File

@@ -77,6 +77,7 @@ public class TestsDatabase extends SQLiteDatabase {
case Done:
case Aborted:
case Draft:
case ConnectionError:
break;
default:
packages.add(p);
@@ -116,6 +117,7 @@ public class TestsDatabase extends SQLiteDatabase {
case Done:
case Aborted:
case Draft:
case ConnectionError:
break;
default:
//активен.

View File

@@ -96,7 +96,9 @@ public class UserConnection {
if (sftpChannel != null) sftpChannel.disconnect();
if (shellChannel != null) shellChannel.disconnect();
if (execChannel != null) execChannel.disconnect();
if (session != null) session.disconnect();
if (session != null) {
session.disconnect();
}
//----------------------
sftpChannel = null;
shellChannel = null;