++
Исправлены баги с рассылкой и размножением сообщений.
This commit is contained in:
11
.idea/workspace.xml
generated
11
.idea/workspace.xml
generated
@@ -7,8 +7,17 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<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/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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"ServerUserPassword": "mprit_2011",
|
"ServerUserPassword": "mprit_2011",
|
||||||
"OfferRegistrationOnStart": true,
|
"OfferRegistrationOnStart": true,
|
||||||
"Workspace": "E:\\Tests",
|
"Workspace": "E:\\Tests",
|
||||||
"ProjectsSearchDirectory": "E:\\Tests\\Downloads\\sadp110_1741361715\\sadp110\\v1\\v1",
|
"ProjectsSearchDirectory": "E:\\BUG",
|
||||||
"DocumentsDirectory": "C:\\Users\\misha\\Documents\\_testing_system",
|
"DocumentsDirectory": "C:\\Users\\misha\\Documents\\_testing_system",
|
||||||
"VisualiserPath": "C:\\Users\\misha\\Downloads",
|
"VisualiserPath": "C:\\Users\\misha\\Downloads",
|
||||||
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
|
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
|
||||||
|
|||||||
@@ -76,15 +76,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@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() {
|
public void ActivateDB() {
|
||||||
super.ActivateDB();
|
super.ActivateDB();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5,14 +5,6 @@ import java.io.File;
|
|||||||
public class ComponentsServerProperties extends VisualDVMProperties{
|
public class ComponentsServerProperties extends VisualDVMProperties{
|
||||||
//---
|
//---
|
||||||
@Expose
|
@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;
|
public int ComponentsBackUpsCount = 10;
|
||||||
@Expose
|
@Expose
|
||||||
public String default_dvm_drv="";
|
public String default_dvm_drv="";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Common.Utils.Vector_;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class Constants {
|
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 planner_version = 12;
|
||||||
public static final int testingMaxKernels = 64;
|
public static final int testingMaxKernels = 64;
|
||||||
//--
|
//--
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ public class ArchivesBackupPass extends ConnectionPass<File> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
String workspace_path = Utils_.toU(Paths.get(user.connection.sftpChannel.getHome(), Global.componentsServerProperties.BackupWorkspace).toString());
|
RemoteFile workspace = new RemoteFile(user.connection.sftpChannel.getHome(), "_sapfor_x64_backups", true);
|
||||||
RemoteFile workspace = new RemoteFile(workspace_path, true);
|
|
||||||
user.connection.MKDIR(workspace);
|
user.connection.MKDIR(workspace);
|
||||||
RemoteFile dst = new RemoteFile(workspace.full_name, src.getName());
|
RemoteFile dst = new RemoteFile(workspace.full_name, src.getName());
|
||||||
user.connection.putSingleFile(src, dst);
|
user.connection.putSingleFile(src, dst);
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ public class PublishComponent extends ComponentsServerPass<Component> {
|
|||||||
if (f.fields.cbForceMail.isSelected())
|
if (f.fields.cbForceMail.isSelected())
|
||||||
message.addAttachement(target.getFile());
|
message.addAttachement(target.getFile());
|
||||||
//--
|
//--
|
||||||
//todo потом сделать красивее. на сторону сервера это безобразие
|
|
||||||
Pass unsafeEmail = new Email(){
|
Pass unsafeEmail = new Email(){
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
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 org.apache.commons.io.FileUtils;
|
||||||
import sun.misc.SignalHandler;
|
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.io.*;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@@ -33,7 +25,10 @@ import java.util.*;
|
|||||||
public abstract class RepositoryServer<D extends Database> {
|
public abstract class RepositoryServer<D extends Database> {
|
||||||
protected static FileWriter Log;
|
protected static FileWriter Log;
|
||||||
protected static boolean printOn = true;
|
protected static boolean printOn = true;
|
||||||
public String getServerFileName(){return Constants.ApplicationFileName;};
|
public String getServerFileName() {
|
||||||
|
return Constants.ApplicationFileName;
|
||||||
|
}
|
||||||
|
;
|
||||||
public abstract String getServerHomeName();
|
public abstract String getServerHomeName();
|
||||||
//-
|
//-
|
||||||
public D db;
|
public D db;
|
||||||
@@ -46,6 +41,7 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
//-
|
//-
|
||||||
protected ServerCode code;
|
protected ServerCode code;
|
||||||
protected long count = 0; //для отладки.
|
protected long count = 0; //для отладки.
|
||||||
|
EmailChecker emailChecker = null;
|
||||||
BackUpsChecker backUpsChecker = null;
|
BackUpsChecker backUpsChecker = null;
|
||||||
/*
|
/*
|
||||||
public static Vector<Pair<Machine, User>> storages = new Vector<>(
|
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;
|
Class<D> d_class;
|
||||||
//-----------RECURSION ->
|
//-----------RECURSION ->
|
||||||
SignalHandler signalHandler = signal -> {
|
SignalHandler signalHandler = signal -> {
|
||||||
@@ -79,6 +61,8 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
public static UnzipFolderPass unzip = new UnzipFolderPass();
|
public static UnzipFolderPass unzip = new UnzipFolderPass();
|
||||||
public static ArchivesBackupPass backupSession = new ArchivesBackupPass();
|
public static ArchivesBackupPass backupSession = new ArchivesBackupPass();
|
||||||
//--
|
//--
|
||||||
|
public static Vector<Pair<String, EmailMessage>> EmailMessagesQueue = null;
|
||||||
|
//--
|
||||||
public RepositoryServer(Class<D> d_class_in) {
|
public RepositoryServer(Class<D> d_class_in) {
|
||||||
d_class = d_class_in;
|
d_class = d_class_in;
|
||||||
}
|
}
|
||||||
@@ -107,8 +91,11 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
}
|
}
|
||||||
//-DVMTestingChecker
|
//-DVMTestingChecker
|
||||||
public abstract int getPort();
|
public abstract int getPort();
|
||||||
protected void Session() throws Exception {};
|
protected void Session() throws Exception {
|
||||||
protected void UnsafeSession() throws Exception {}
|
}
|
||||||
|
;
|
||||||
|
protected void UnsafeSession() throws Exception {
|
||||||
|
}
|
||||||
protected void startAdditionalThreads() {
|
protected void startAdditionalThreads() {
|
||||||
}
|
}
|
||||||
public void ActivateDB() {
|
public void ActivateDB() {
|
||||||
@@ -119,65 +106,6 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
ex.printStackTrace();
|
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 {
|
public boolean canDelete(DBObject object) throws Exception {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -188,11 +116,36 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
DiagnosticSignalHandler.install("INT", signalHandler);
|
DiagnosticSignalHandler.install("INT", signalHandler);
|
||||||
DiagnosticSignalHandler.install("ABRT", signalHandler);
|
DiagnosticSignalHandler.install("ABRT", signalHandler);
|
||||||
//--
|
//--
|
||||||
interruptThread.start();
|
EmailMessagesQueue = new Vector<>();
|
||||||
|
emailChecker = new EmailChecker(this);
|
||||||
backUpsChecker = new BackUpsChecker(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();
|
startAdditionalThreads();
|
||||||
|
//--
|
||||||
server = new ServerSocket(getPort());
|
server = new ServerSocket(getPort());
|
||||||
StartAction();
|
StartAction();
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -218,9 +171,9 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
try {
|
try {
|
||||||
code = request.getCode();
|
code = request.getCode();
|
||||||
//--
|
//--
|
||||||
if (transport instanceof SafeServerExchangeUnit){
|
if (transport instanceof SafeServerExchangeUnit) {
|
||||||
SafeServerExchangeUnit safe_request= (SafeServerExchangeUnit) transport;
|
SafeServerExchangeUnit safe_request = (SafeServerExchangeUnit) transport;
|
||||||
if (safe_request.version!=Constants.version){
|
if (safe_request.version != Constants.version) {
|
||||||
//версия не совпала. не даем работать.
|
//версия не совпала. не даем работать.
|
||||||
throw new RepositoryRefuseException("Версия клиента не совпадает с версией сервера!");
|
throw new RepositoryRefuseException("Версия клиента не совпадает с версией сервера!");
|
||||||
}
|
}
|
||||||
@@ -229,6 +182,9 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
case Email:
|
case Email:
|
||||||
Email();
|
Email();
|
||||||
break;
|
break;
|
||||||
|
case GetFirstEmailToSend:
|
||||||
|
GetFirstEmailToSend();
|
||||||
|
break;
|
||||||
case CreateBackUp:
|
case CreateBackUp:
|
||||||
CreateBackUp();
|
CreateBackUp();
|
||||||
break;
|
break;
|
||||||
@@ -260,9 +216,9 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
Session();
|
Session();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
//ОПАСНАЯ СЕССИЯ
|
//ОПАСНАЯ СЕССИЯ
|
||||||
switch (code){
|
switch (code) {
|
||||||
case Ping:
|
case Ping:
|
||||||
Ping();
|
Ping();
|
||||||
break;
|
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() {
|
public boolean PingFromClient() {
|
||||||
RepositoryPass pingPass = new RepositoryPass(this) {
|
RepositoryPass pingPass = new RepositoryPass(this) {
|
||||||
boolean success;
|
boolean success;
|
||||||
@@ -356,9 +324,6 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
File file = new File(request.arg);
|
File file = new File(request.arg);
|
||||||
response.object = file.exists() ? Utils_.fileToBytes(file) : null;
|
response.object = file.exists() ? Utils_.fileToBytes(file) : null;
|
||||||
}
|
}
|
||||||
void Email() throws Exception {
|
|
||||||
Email((EmailMessage) request.object, request.arg);
|
|
||||||
}
|
|
||||||
void CreateBackUp() throws Exception {
|
void CreateBackUp() throws Exception {
|
||||||
//определить имя папки с багом.
|
//определить имя папки с багом.
|
||||||
boolean force = (boolean) request.object;
|
boolean force = (boolean) request.object;
|
||||||
@@ -371,7 +336,7 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
String backUpName = year + "_" + (month + 1) + "_" + (day);
|
String backUpName = year + "_" + (month + 1) + "_" + (day);
|
||||||
File todayBackUp = new File(Global.DataBackUpsDirectory, backUpName);
|
File todayBackUp = new File(Global.DataBackUpsDirectory, backUpName);
|
||||||
File todayBackUpArchive = new File(Global.DataBackUpsDirectory, backUpName + ".zip");
|
File todayBackUpArchive = new File(Global.DataBackUpsDirectory, backUpName + ".zip");
|
||||||
if (force&&todayBackUpArchive.exists())
|
if (force && todayBackUpArchive.exists())
|
||||||
Utils_.forceDeleteWithCheck(todayBackUpArchive);
|
Utils_.forceDeleteWithCheck(todayBackUpArchive);
|
||||||
//-
|
//-
|
||||||
// Чистка старых бекапов на самом сервере.
|
// Чистка старых бекапов на самом сервере.
|
||||||
@@ -392,17 +357,15 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
// }
|
// }
|
||||||
//bonus backup
|
//bonus backup
|
||||||
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
|
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);
|
message.addAttachement(todayBackUpArchive);
|
||||||
for (String address : Constants.admins_mails) {
|
for (String address : Constants.admins_mails)
|
||||||
Email(message, address);
|
EmailMessagesQueue.add(new Pair<>(address,message));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
protected void extraBackup(File todayBackUp){
|
|
||||||
|
|
||||||
|
protected void extraBackup(File todayBackUp) {
|
||||||
}
|
}
|
||||||
//----
|
//----
|
||||||
void PublishObject() throws Exception {
|
void PublishObject() throws Exception {
|
||||||
@@ -460,14 +423,18 @@ public abstract class RepositoryServer<D extends Database> {
|
|||||||
afterDeleteAction(db.DeleteByPK(to_delete.getKey(), object));
|
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 {
|
||||||
}
|
//
|
||||||
protected void afterPublishAction(DBObject object) throws Exception {
|
if (EmailMessagesQueue.isEmpty()){
|
||||||
}
|
response.object = null;
|
||||||
protected void afterEditAction(DBObject object) throws Exception {
|
}else {
|
||||||
}
|
response.object = EmailMessagesQueue.lastElement();
|
||||||
protected void afterDeleteAction(DBObject object) throws Exception {
|
EmailMessagesQueue.removeElementAt(EmailMessagesQueue.size()-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,9 +69,18 @@ public enum ServerCode {
|
|||||||
PublishUserAccount,
|
PublishUserAccount,
|
||||||
DeleteUserAccount,
|
DeleteUserAccount,
|
||||||
GetDVMPackageCredentials,
|
GetDVMPackageCredentials,
|
||||||
CreateBackUp;
|
CreateBackUp,
|
||||||
|
GetFirstEmailToSend;
|
||||||
public String getDescription(){
|
public String getDescription(){
|
||||||
switch (this){
|
switch (this){
|
||||||
|
case Email:
|
||||||
|
return "Создать сообщение электронной почты на сервере";
|
||||||
|
case GetFirstEmailToSend:
|
||||||
|
return "Получить сообщение электронной почты для отправки на сервере";
|
||||||
|
case ReplaceTestsCodes:
|
||||||
|
return "Заменить код тестов на сервере";
|
||||||
|
case ActualizeDVMPackages:
|
||||||
|
return "Обновить информацию о пакетах тестирования DVM на сервере";
|
||||||
case CreateBackUp:
|
case CreateBackUp:
|
||||||
return "Создание резервной копии данных сервера";
|
return "Создание резервной копии данных сервера";
|
||||||
case GetDVMPackageCredentials:
|
case GetDVMPackageCredentials:
|
||||||
|
|||||||
@@ -60,18 +60,11 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
//------>>>
|
//------>>>
|
||||||
public static Timer checkTimer = null;
|
public static Timer checkTimer = null;
|
||||||
public String name = "?";
|
public String name = "?";
|
||||||
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
DVMTestingChecker dvmTestingChecker = null;
|
||||||
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
SapforTestingPlanner sapforTestingPlanner = null;
|
||||||
//-->
|
//-->
|
||||||
MachinesDatabase machines_db;
|
MachinesDatabase machines_db;
|
||||||
//-->
|
//-->
|
||||||
protected Thread testingThread = new Thread(() -> {
|
|
||||||
while (true) {
|
|
||||||
dvmTestingChecker.Perform();
|
|
||||||
sapforTestingPlanner.Perform();
|
|
||||||
Utils_.sleep(5000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
public TestingServer() {
|
public TestingServer() {
|
||||||
super(TestsDatabase.class);
|
super(TestsDatabase.class);
|
||||||
name = Utils_.getDateName("testingServer");
|
name = Utils_.getDateName("testingServer");
|
||||||
@@ -87,10 +80,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void extraBackup(File todayBackUp) {
|
protected void extraBackup(File todayBackUp) {
|
||||||
zip.Do("Tests", new File (todayBackUp, "Tests.zip").getAbsolutePath());
|
zip.Do("Tests", new File(todayBackUp, "Tests.zip").getAbsolutePath());
|
||||||
zip.Do("Sapfors", new File (todayBackUp, "Sapfors.zip").getAbsolutePath());
|
zip.Do("Sapfors", new File(todayBackUp, "Sapfors.zip").getAbsolutePath());
|
||||||
zip.Do("DVMPackages", new File (todayBackUp, "DVMPackages.zip").getAbsolutePath());
|
zip.Do("DVMPackages", new File(todayBackUp, "DVMPackages.zip").getAbsolutePath());
|
||||||
zip.Do("SapforPackages", new File (todayBackUp, "SapforPackages.zip").getAbsolutePath());
|
zip.Do("SapforPackages", new File(todayBackUp, "SapforPackages.zip").getAbsolutePath());
|
||||||
}
|
}
|
||||||
public static void TimerOn() {
|
public static void TimerOn() {
|
||||||
checkTimer = new Timer(Global.normalProperties.CheckTestingIntervalSeconds * 1000, e -> {
|
checkTimer = new Timer(Global.normalProperties.CheckTestingIntervalSeconds * 1000, e -> {
|
||||||
@@ -294,7 +287,15 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void startAdditionalThreads() {
|
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 {
|
void PerformAutoSapforTesting() throws Exception {
|
||||||
TextLog Log = new TextLog();
|
TextLog Log = new TextLog();
|
||||||
@@ -307,9 +308,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
||||||
Log.toString()
|
Log.toString()
|
||||||
);
|
);
|
||||||
for (String address : Constants.admins_mails) {
|
for (String address : Constants.admins_mails)
|
||||||
Email(message, address);
|
EmailMessagesQueue.add(new Pair<>(address,message));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void DownloadTest() throws Exception {
|
void DownloadTest() throws Exception {
|
||||||
int test_id = Integer.parseInt(request.arg);
|
int test_id = Integer.parseInt(request.arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user