рефакторинг бекапов. бекапы для тестирования. бекапы по кнопке

++
This commit is contained in:
2025-03-08 02:42:21 +03:00
parent e428d621ac
commit c4157fc30b
18 changed files with 275 additions and 149 deletions

View File

@@ -3,76 +3,16 @@ import Common.Passes.PassException;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.Server.RepositoryPass;
import _VisualDVM.Repository.Server.RepositoryServerClient;
import _VisualDVM.Repository.Server.SafeServerExchangeUnit;
import _VisualDVM.Repository.Server.ServerCode;
import java.io.FileWriter;
import java.io.Serializable;
import java.util.Date;
public abstract class TestingClient {
//--
protected int getSleepMillis() {
return 2000;
}
//---
protected boolean isPrintOn() {
return true;
}
protected void Print(String message) {
try {
if (isPrintOn()) {
FileWriter testLog = new FileWriter(getClass().getSimpleName() + "_Log.txt", true);
String dmessage = Utils_.Brackets(new Date()) + " " + message;
testLog.write(dmessage + "\n");
testLog.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
//--
protected Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
RepositoryPass<TestingServer,Object> pass = new RepositoryPass<TestingServer, Object>(Global.testingServer) {
@Override
public String getDescription() {
return "";
}
@Override
protected void ServerAction() throws Exception {
Command(new SafeServerExchangeUnit(code_in, arg, object_in));
target = server_response.object;
}
@Override
protected boolean validate() {
return Log.isEmpty();
}
@Override
protected int getTimeout() {
return 0;
}
};
if (!pass.Do()) {
ServerConnectionError(code_in, pass.Log.toString());
}
return pass.target;
}
protected Object ServerCommand(ServerCode code_in, Serializable object_in) throws Exception {
return ServerCommand(code_in, "", object_in);
}
protected Object ServerCommand(ServerCode code_in) throws Exception {
return ServerCommand(code_in, "", null);
}
protected void ServerConnectionError(ServerCode code_in, String logText) throws Exception {
throw new PassException(Utils_.Brackets(new Date().toString()) + " Ошибка взаимодействия с сервером " + code_in);
}
public abstract void perform() throws Exception;
public void Perform() {
try {
perform();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
Utils_.sleep(getSleepMillis());
}
public abstract class TestingClient extends RepositoryServerClient<TestingServer> {
@Override
protected TestingServer getServer() {
return Global.testingServer;
}
}

View File

@@ -86,7 +86,10 @@ public class TestingMenuBar extends VisualiserMenuBar {
});
addSeparator();
serverAdminLabel = addLabel(" управление сервером ");
addPasses(PassCode.StartTestingServer, PassCode.ShutdownTestingServer, PassCode.PublishTestingServer);
addPasses(PassCode.StartTestingServer,
PassCode.ShutdownTestingServer,
PassCode.PublishTestingServer,
PassCode.TestingServerBackUp);
}
public void ShowAutoCheckTesting() {
autorefreshButton.setIcon(Utils_.getIcon(Global.normalProperties.AutoCheckTesting ? "/Common/icons/Pick.png" : "/Common/icons/NotPick.png"));

View File

@@ -85,6 +85,13 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
ex.printStackTrace();
}
}
@Override
protected void extraBackup(File todayBackUp) {
zip.Do("Tests", new File (todayBackUp, "Tests.zip").getAbsolutePath());
zip.Do("Sapfors", new File (todayBackUp, "Sapfors.zip").getAbsolutePath());
zip.Do("DVMPackages", new File (todayBackUp, "DVMPackages.zip").getAbsolutePath());
zip.Do("SapforPackages", new File (todayBackUp, "SapforPackages.zip").getAbsolutePath());
}
public static void TimerOn() {
checkTimer = new Timer(Global.normalProperties.CheckTestingIntervalSeconds * 1000, e -> {
Global.mainModule.getPass(PassCode.ActualizePackages).Do();