++
Исправлены баги с рассылкой и размножением сообщений.
This commit is contained in:
11
.idea/workspace.xml
generated
11
.idea/workspace.xml
generated
@@ -7,8 +7,17 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/BackUpsChecker.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/BackUpsChecker.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/EmailChecker.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/ComponentsServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/ComponentsServer.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServerProperties.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServerProperties.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/ArchivesBackupPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/ArchivesBackupPass.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishComponent.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishComponent.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/RepositoryServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/RepositoryServer.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/ServerCode.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"ServerUserPassword": "mprit_2011",
|
||||
"OfferRegistrationOnStart": true,
|
||||
"Workspace": "E:\\Tests",
|
||||
"ProjectsSearchDirectory": "E:\\Tests\\Downloads\\sadp110_1741361715\\sadp110\\v1\\v1",
|
||||
"ProjectsSearchDirectory": "E:\\BUG",
|
||||
"DocumentsDirectory": "C:\\Users\\misha\\Documents\\_testing_system",
|
||||
"VisualiserPath": "C:\\Users\\misha\\Downloads",
|
||||
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
|
||||
|
||||
@@ -76,15 +76,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void StartAction() throws Exception {
|
||||
if (Global.componentsServerProperties.EmailAdminsOnStart) {
|
||||
EmailMessage message = new EmailMessage("Сервер Sapfor запущен", new Date().toString());
|
||||
for (String address : Constants.admins_mails) {
|
||||
Email(message, address);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void ActivateDB() {
|
||||
super.ActivateDB();
|
||||
try {
|
||||
|
||||
@@ -5,14 +5,6 @@ import java.io.File;
|
||||
public class ComponentsServerProperties extends VisualDVMProperties{
|
||||
//---
|
||||
@Expose
|
||||
public boolean EmailAdminsOnStart = false;
|
||||
@Expose
|
||||
public String BackupWorkspace = "_sapfor_x64_backups";
|
||||
@Expose
|
||||
public int BackupHour = 5;
|
||||
@Expose
|
||||
public int BackupMinute = 0;
|
||||
@Expose
|
||||
public int ComponentsBackUpsCount = 10;
|
||||
@Expose
|
||||
public String default_dvm_drv="";
|
||||
|
||||
@@ -3,7 +3,7 @@ import Common.Utils.Vector_;
|
||||
|
||||
import java.util.Vector;
|
||||
public class Constants {
|
||||
public static final int version = 1201;
|
||||
public static final int version = 1202;
|
||||
public static final int planner_version = 12;
|
||||
public static final int testingMaxKernels = 64;
|
||||
//--
|
||||
|
||||
@@ -26,8 +26,7 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
String workspace_path = Utils_.toU(Paths.get(user.connection.sftpChannel.getHome(), Global.componentsServerProperties.BackupWorkspace).toString());
|
||||
RemoteFile workspace = new RemoteFile(workspace_path, true);
|
||||
RemoteFile workspace = new RemoteFile(user.connection.sftpChannel.getHome(), "_sapfor_x64_backups", true);
|
||||
user.connection.MKDIR(workspace);
|
||||
RemoteFile dst = new RemoteFile(workspace.full_name, src.getName());
|
||||
user.connection.putSingleFile(src, dst);
|
||||
|
||||
@@ -90,7 +90,6 @@ public class PublishComponent extends ComponentsServerPass<Component> {
|
||||
if (f.fields.cbForceMail.isSelected())
|
||||
message.addAttachement(target.getFile());
|
||||
//--
|
||||
//todo потом сделать красивее. на сторону сервера это безобразие
|
||||
Pass unsafeEmail = new Email(){
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
85
src/_VisualDVM/Repository/Server/EmailChecker.java
Normal file
85
src/_VisualDVM/Repository/Server/EmailChecker.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package _VisualDVM.Repository.Server;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Utils;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Properties;
|
||||
public class EmailChecker extends RepositoryServerClient {
|
||||
RepositoryServer server;
|
||||
@Override
|
||||
protected RepositoryServer getServer() {
|
||||
return server;
|
||||
}
|
||||
public EmailChecker(RepositoryServer server_in) {
|
||||
server = server_in;
|
||||
}
|
||||
@Override
|
||||
protected int getSleepMillis() {
|
||||
return 5000;
|
||||
}
|
||||
@Override
|
||||
protected void perform() throws Exception {
|
||||
Pair<String, EmailMessage> messagePair = (Pair<String, EmailMessage>) ServerCommand(ServerCode.GetFirstEmailToSend);
|
||||
if (messagePair != null) {
|
||||
SendEmail(messagePair.getKey(), messagePair.getValue());
|
||||
}
|
||||
}
|
||||
public void SendEmail(String address_in, EmailMessage message_in) throws Exception {
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", Constants.SMTPHost);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.port", String.valueOf(Constants.SMTPPort));
|
||||
props.put("mail.smtp.socketFactory.port", String.valueOf(Constants.MailSocketPort));
|
||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||
props.put("mail.smtp.connectiontimeout", String.valueOf(15000));
|
||||
props.put("mail.smtp.timeout", String.valueOf(15000));
|
||||
props.put("mail.smtp.writetimeout", String.valueOf(15000));
|
||||
//------------------------------
|
||||
LinkedHashMap<String, File> innerFiles = new LinkedHashMap<>();
|
||||
for (String aName : message_in.files.keySet()) {
|
||||
File f = Utils.getTempFileName(aName);
|
||||
Utils_.bytesToFile(message_in.files.get(aName), f);
|
||||
innerFiles.put(aName, f);
|
||||
}
|
||||
//------------------------------
|
||||
Session session = Session.getDefaultInstance(props,
|
||||
new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(
|
||||
Constants.MailAddress,
|
||||
Constants.MailPassword);
|
||||
}
|
||||
});
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(Constants.MailAddress));
|
||||
message.setRecipients(Message.RecipientType.CC, InternetAddress.parse(address_in));
|
||||
message.setSubject(message_in.subject);
|
||||
Multipart multipart = new MimeMultipart();
|
||||
MimeBodyPart textBodyPart = new MimeBodyPart();
|
||||
textBodyPart.setText(message_in.text);
|
||||
multipart.addBodyPart(textBodyPart);
|
||||
for (String aName : innerFiles.keySet()) {
|
||||
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
|
||||
DataSource source = new FileDataSource(innerFiles.get(aName));
|
||||
attachmentBodyPart.setDataHandler(new DataHandler(source));
|
||||
attachmentBodyPart.setFileName(aName);
|
||||
multipart.addBodyPart(attachmentBodyPart);
|
||||
}
|
||||
message.setContent(multipart);
|
||||
Transport.send(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,6 @@ import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import sun.misc.SignalHandler;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.*;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
@@ -33,7 +25,10 @@ import java.util.*;
|
||||
public abstract class RepositoryServer<D extends Database> {
|
||||
protected static FileWriter Log;
|
||||
protected static boolean printOn = true;
|
||||
public String getServerFileName(){return Constants.ApplicationFileName;};
|
||||
public String getServerFileName() {
|
||||
return Constants.ApplicationFileName;
|
||||
}
|
||||
;
|
||||
public abstract String getServerHomeName();
|
||||
//-
|
||||
public D db;
|
||||
@@ -46,6 +41,7 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
//-
|
||||
protected ServerCode code;
|
||||
protected long count = 0; //для отладки.
|
||||
EmailChecker emailChecker = null;
|
||||
BackUpsChecker backUpsChecker = null;
|
||||
/*
|
||||
public static Vector<Pair<Machine, User>> storages = new Vector<>(
|
||||
@@ -56,20 +52,6 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
));
|
||||
//-
|
||||
*/
|
||||
|
||||
protected Thread interruptThread = new InterruptThread(10000,
|
||||
() -> {
|
||||
System.exit(0);
|
||||
return null;
|
||||
});
|
||||
protected Thread backUpsThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
backUpsChecker.Perform();
|
||||
}
|
||||
}
|
||||
});
|
||||
Class<D> d_class;
|
||||
//-----------RECURSION ->
|
||||
SignalHandler signalHandler = signal -> {
|
||||
@@ -79,6 +61,8 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
public static UnzipFolderPass unzip = new UnzipFolderPass();
|
||||
public static ArchivesBackupPass backupSession = new ArchivesBackupPass();
|
||||
//--
|
||||
public static Vector<Pair<String, EmailMessage>> EmailMessagesQueue = null;
|
||||
//--
|
||||
public RepositoryServer(Class<D> d_class_in) {
|
||||
d_class = d_class_in;
|
||||
}
|
||||
@@ -107,8 +91,11 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
}
|
||||
//-DVMTestingChecker
|
||||
public abstract int getPort();
|
||||
protected void Session() throws Exception {};
|
||||
protected void UnsafeSession() throws Exception {}
|
||||
protected void Session() throws Exception {
|
||||
}
|
||||
;
|
||||
protected void UnsafeSession() throws Exception {
|
||||
}
|
||||
protected void startAdditionalThreads() {
|
||||
}
|
||||
public void ActivateDB() {
|
||||
@@ -119,65 +106,6 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void Email(EmailMessage message_in, String address_in) throws Exception {
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", Constants.SMTPHost);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.port", String.valueOf(Constants.SMTPPort));
|
||||
props.put("mail.smtp.socketFactory.port", String.valueOf(Constants.MailSocketPort));
|
||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||
props.put("mail.smtp.connectiontimeout", String.valueOf(15000));
|
||||
props.put("mail.smtp.timeout", String.valueOf(15000));
|
||||
props.put("mail.smtp.writetimeout", String.valueOf(15000));
|
||||
//------------------------------
|
||||
LinkedHashMap<String, File> innerFiles = new LinkedHashMap<>();
|
||||
for (String aName : message_in.files.keySet()) {
|
||||
File f = Utils.getTempFileName(aName);
|
||||
Utils_.bytesToFile(message_in.files.get(aName), f);
|
||||
innerFiles.put(aName, f);
|
||||
}
|
||||
//------------------------------
|
||||
Session session = Session.getDefaultInstance(props,
|
||||
new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(
|
||||
Constants.MailAddress,
|
||||
Constants.MailPassword);
|
||||
}
|
||||
});
|
||||
try {
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(Constants.MailAddress));
|
||||
message.setRecipients(Message.RecipientType.CC, InternetAddress.parse(address_in));
|
||||
message.setSubject(message_in.subject);
|
||||
Multipart multipart = new MimeMultipart();
|
||||
MimeBodyPart textBodyPart = new MimeBodyPart();
|
||||
textBodyPart.setText(message_in.text);
|
||||
multipart.addBodyPart(textBodyPart);
|
||||
for (String aName : innerFiles.keySet()) {
|
||||
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
|
||||
DataSource source = new FileDataSource(innerFiles.get(aName));
|
||||
attachmentBodyPart.setDataHandler(new DataHandler(source));
|
||||
attachmentBodyPart.setFileName(aName);
|
||||
multipart.addBodyPart(attachmentBodyPart);
|
||||
}
|
||||
message.setContent(multipart);
|
||||
Transport.send(message);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Исключение во время отправки сообщения абоненту " + Utils_.Brackets(address_in));
|
||||
ex.printStackTrace();
|
||||
Utils_.sleep(1000);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Исключение во время выполнения рассылки.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
public boolean canDelete(DBObject object) throws Exception {
|
||||
return true;
|
||||
}
|
||||
@@ -188,11 +116,36 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
DiagnosticSignalHandler.install("INT", signalHandler);
|
||||
DiagnosticSignalHandler.install("ABRT", signalHandler);
|
||||
//--
|
||||
interruptThread.start();
|
||||
EmailMessagesQueue = new Vector<>();
|
||||
emailChecker = new EmailChecker(this);
|
||||
backUpsChecker = new BackUpsChecker(this);
|
||||
backUpsThread.start();
|
||||
//--
|
||||
new InterruptThread(10000,
|
||||
() -> {
|
||||
System.exit(0);
|
||||
return null;
|
||||
}).start();
|
||||
//--
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
emailChecker.Perform();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
//--
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
backUpsChecker.Perform();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
//--
|
||||
startAdditionalThreads();
|
||||
//--
|
||||
server = new ServerSocket(getPort());
|
||||
StartAction();
|
||||
while (true) {
|
||||
@@ -218,9 +171,9 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
try {
|
||||
code = request.getCode();
|
||||
//--
|
||||
if (transport instanceof SafeServerExchangeUnit){
|
||||
SafeServerExchangeUnit safe_request= (SafeServerExchangeUnit) transport;
|
||||
if (safe_request.version!=Constants.version){
|
||||
if (transport instanceof SafeServerExchangeUnit) {
|
||||
SafeServerExchangeUnit safe_request = (SafeServerExchangeUnit) transport;
|
||||
if (safe_request.version != Constants.version) {
|
||||
//версия не совпала. не даем работать.
|
||||
throw new RepositoryRefuseException("Версия клиента не совпадает с версией сервера!");
|
||||
}
|
||||
@@ -229,6 +182,9 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
case Email:
|
||||
Email();
|
||||
break;
|
||||
case GetFirstEmailToSend:
|
||||
GetFirstEmailToSend();
|
||||
break;
|
||||
case CreateBackUp:
|
||||
CreateBackUp();
|
||||
break;
|
||||
@@ -260,9 +216,9 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
Session();
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
//ОПАСНАЯ СЕССИЯ
|
||||
switch (code){
|
||||
switch (code) {
|
||||
case Ping:
|
||||
Ping();
|
||||
break;
|
||||
@@ -315,7 +271,19 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
}
|
||||
}
|
||||
//--
|
||||
void Ping() {}
|
||||
protected void afterCloneAction(riDBObject src, riDBObject dst) throws Exception {
|
||||
}
|
||||
protected void beforePublishAction(DBObject object) throws Exception {
|
||||
}
|
||||
protected void afterPublishAction(DBObject object) throws Exception {
|
||||
}
|
||||
protected void afterEditAction(DBObject object) throws Exception {
|
||||
}
|
||||
protected void afterDeleteAction(DBObject object) throws Exception {
|
||||
}
|
||||
//--
|
||||
void Ping() {
|
||||
}
|
||||
public boolean PingFromClient() {
|
||||
RepositoryPass pingPass = new RepositoryPass(this) {
|
||||
boolean success;
|
||||
@@ -356,9 +324,6 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
File file = new File(request.arg);
|
||||
response.object = file.exists() ? Utils_.fileToBytes(file) : null;
|
||||
}
|
||||
void Email() throws Exception {
|
||||
Email((EmailMessage) request.object, request.arg);
|
||||
}
|
||||
void CreateBackUp() throws Exception {
|
||||
//определить имя папки с багом.
|
||||
boolean force = (boolean) request.object;
|
||||
@@ -371,7 +336,7 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
String backUpName = year + "_" + (month + 1) + "_" + (day);
|
||||
File todayBackUp = new File(Global.DataBackUpsDirectory, backUpName);
|
||||
File todayBackUpArchive = new File(Global.DataBackUpsDirectory, backUpName + ".zip");
|
||||
if (force&&todayBackUpArchive.exists())
|
||||
if (force && todayBackUpArchive.exists())
|
||||
Utils_.forceDeleteWithCheck(todayBackUpArchive);
|
||||
//-
|
||||
// Чистка старых бекапов на самом сервере.
|
||||
@@ -392,17 +357,15 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
// }
|
||||
//bonus backup
|
||||
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
|
||||
EmailMessage message = new EmailMessage(getClass().getSimpleName()+" BackUp",
|
||||
"Резервная копия файлов");
|
||||
EmailMessage message = new EmailMessage(getClass().getSimpleName() + " BackUp","Резервная копия файлов");
|
||||
message.addAttachement(todayBackUpArchive);
|
||||
for (String address : Constants.admins_mails) {
|
||||
Email(message, address);
|
||||
for (String address : Constants.admins_mails)
|
||||
EmailMessagesQueue.add(new Pair<>(address,message));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
protected void extraBackup(File todayBackUp){
|
||||
|
||||
protected void extraBackup(File todayBackUp) {
|
||||
}
|
||||
//----
|
||||
void PublishObject() throws Exception {
|
||||
@@ -460,14 +423,18 @@ public abstract class RepositoryServer<D extends Database> {
|
||||
afterDeleteAction(db.DeleteByPK(to_delete.getKey(), object));
|
||||
}
|
||||
}
|
||||
protected void afterCloneAction(riDBObject src, riDBObject dst) throws Exception {
|
||||
//--
|
||||
void Email() throws Exception {
|
||||
//положить в очередь сообщений.
|
||||
EmailMessagesQueue.add(new Pair<>(request.arg, (EmailMessage) request.object));
|
||||
}
|
||||
protected void beforePublishAction(DBObject object) throws Exception {
|
||||
void GetFirstEmailToSend() throws Exception {
|
||||
//
|
||||
if (EmailMessagesQueue.isEmpty()){
|
||||
response.object = null;
|
||||
}else {
|
||||
response.object = EmailMessagesQueue.lastElement();
|
||||
EmailMessagesQueue.removeElementAt(EmailMessagesQueue.size()-1);
|
||||
}
|
||||
protected void afterPublishAction(DBObject object) throws Exception {
|
||||
}
|
||||
protected void afterEditAction(DBObject object) throws Exception {
|
||||
}
|
||||
protected void afterDeleteAction(DBObject object) throws Exception {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,18 @@ public enum ServerCode {
|
||||
PublishUserAccount,
|
||||
DeleteUserAccount,
|
||||
GetDVMPackageCredentials,
|
||||
CreateBackUp;
|
||||
CreateBackUp,
|
||||
GetFirstEmailToSend;
|
||||
public String getDescription(){
|
||||
switch (this){
|
||||
case Email:
|
||||
return "Создать сообщение электронной почты на сервере";
|
||||
case GetFirstEmailToSend:
|
||||
return "Получить сообщение электронной почты для отправки на сервере";
|
||||
case ReplaceTestsCodes:
|
||||
return "Заменить код тестов на сервере";
|
||||
case ActualizeDVMPackages:
|
||||
return "Обновить информацию о пакетах тестирования DVM на сервере";
|
||||
case CreateBackUp:
|
||||
return "Создание резервной копии данных сервера";
|
||||
case GetDVMPackageCredentials:
|
||||
|
||||
@@ -60,18 +60,11 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
//------>>>
|
||||
public static Timer checkTimer = null;
|
||||
public String name = "?";
|
||||
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
||||
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
||||
DVMTestingChecker dvmTestingChecker = null;
|
||||
SapforTestingPlanner sapforTestingPlanner = null;
|
||||
//-->
|
||||
MachinesDatabase machines_db;
|
||||
//-->
|
||||
protected Thread testingThread = new Thread(() -> {
|
||||
while (true) {
|
||||
dvmTestingChecker.Perform();
|
||||
sapforTestingPlanner.Perform();
|
||||
Utils_.sleep(5000);
|
||||
}
|
||||
});
|
||||
public TestingServer() {
|
||||
super(TestsDatabase.class);
|
||||
name = Utils_.getDateName("testingServer");
|
||||
@@ -87,10 +80,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
}
|
||||
@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());
|
||||
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 -> {
|
||||
@@ -294,7 +287,15 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
}
|
||||
@Override
|
||||
protected void startAdditionalThreads() {
|
||||
testingThread.start();
|
||||
dvmTestingChecker = new DVMTestingChecker();
|
||||
sapforTestingPlanner = new SapforTestingPlanner();
|
||||
new Thread(() -> {
|
||||
while (true) {
|
||||
dvmTestingChecker.Perform();
|
||||
sapforTestingPlanner.Perform();
|
||||
Utils_.sleep(5000);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
void PerformAutoSapforTesting() throws Exception {
|
||||
TextLog Log = new TextLog();
|
||||
@@ -307,9 +308,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
||||
Log.toString()
|
||||
);
|
||||
for (String address : Constants.admins_mails) {
|
||||
Email(message, address);
|
||||
}
|
||||
for (String address : Constants.admins_mails)
|
||||
EmailMessagesQueue.add(new Pair<>(address,message));
|
||||
}
|
||||
void DownloadTest() throws Exception {
|
||||
int test_id = Integer.parseInt(request.arg);
|
||||
|
||||
Reference in New Issue
Block a user