no message
This commit is contained in:
@@ -2,12 +2,14 @@ package _VisualDVM.Repository.Server;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.Passes.All.ArchivesBackupPass;
|
||||
import _VisualDVM.Passes.All.UnzipFolderPass;
|
||||
import _VisualDVM.Passes.All.ZipFolderPass;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.BugReport.BugReport;
|
||||
import _VisualDVM.Repository.BugReport.BugReportInterface;
|
||||
@@ -17,9 +19,7 @@ import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Repository.RepositoryRefuseException;
|
||||
import _VisualDVM.Repository.RepositoryServer;
|
||||
import _VisualDVM.Repository.Subscribes.Subscriber;
|
||||
import _VisualDVM.Passes.All.ArchivesBackupPass;
|
||||
import _VisualDVM.Passes.All.UnzipFolderPass;
|
||||
import _VisualDVM.Passes.All.ZipFolderPass;
|
||||
import _VisualDVM.Utils;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -31,6 +31,75 @@ import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
public static final String server_dvm_drv = "/home/DVM/dvm_current/dvm_sys/bin/dvm_drv";
|
||||
public static ZipFolderPass zip = new ZipFolderPass();
|
||||
public static UnzipFolderPass unzip = new UnzipFolderPass();
|
||||
public static ArchivesBackupPass backupSession = new ArchivesBackupPass();
|
||||
//-
|
||||
public static Vector<Pair<Machine, User>> storages =
|
||||
new Vector<>(Arrays.asList(
|
||||
new Pair<>(
|
||||
new Machine("titan", "dvmh.keldysh.ru", 22, MachineType.Server),
|
||||
new User("dvmuser1", "mprit_2011"))
|
||||
/*
|
||||
new Pair<>(
|
||||
new Machine("k100", "k100.kiam.ru", 22, MachineType.Server),
|
||||
new User("dvmuser1", "mprit_2011"))
|
||||
*/
|
||||
)
|
||||
);
|
||||
//-
|
||||
protected Thread backUp = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
//-------------------------------------
|
||||
Calendar rightNow = Calendar.getInstance();
|
||||
int year = rightNow.get(Calendar.YEAR);
|
||||
int month = rightNow.get(Calendar.MONTH);
|
||||
int day = rightNow.get(Calendar.DAY_OF_MONTH);
|
||||
int hour = rightNow.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = rightNow.get(Calendar.MINUTE);
|
||||
if ((hour == Global.properties.BackupHour) && (minute == Global.properties.BackupMinute)) {
|
||||
//определить имя папки с багом.
|
||||
String backUpName = year + "_" + (month + 1) + "_" + (day);
|
||||
File todayBackUp = Paths.get(Global.DataBackUpsDirectory.getAbsolutePath(), backUpName).toFile();
|
||||
File todayBackUpArchive = Paths.get(Global.DataBackUpsDirectory.getAbsolutePath(), backUpName + ".zip").toFile();
|
||||
//-
|
||||
File bugsDBBackUp = Paths.get(todayBackUp.getAbsolutePath(), db.getFile().getName()).toFile();
|
||||
File bugsArchives = Paths.get(todayBackUp.getAbsolutePath(), "Bugs.zip").toFile();
|
||||
//-
|
||||
// Чистка старых бекапов на самом сервере.
|
||||
Utils.keepNewFiles(todayBackUp.getParentFile(), 2);
|
||||
if (!todayBackUpArchive.exists()) {
|
||||
FileUtils.forceMkdir(todayBackUp);
|
||||
Files.copy(db.getFile().toPath(), bugsDBBackUp.toPath());
|
||||
//-
|
||||
zip.Do("Bugs", bugsArchives.getAbsolutePath());
|
||||
zip.Do(todayBackUp.getAbsolutePath(), todayBackUpArchive.getAbsolutePath());
|
||||
Utils_.forceDeleteWithCheck(todayBackUp);
|
||||
//-
|
||||
for (Pair<Machine, User> cred : storages) {
|
||||
backupSession.Do(cred.getKey(), cred.getValue(),
|
||||
todayBackUpArchive
|
||||
);
|
||||
}
|
||||
//bonus backup
|
||||
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
|
||||
EmailMessage message = new EmailMessage(
|
||||
"db backup",
|
||||
"копия баз данных журнала ошибок",
|
||||
new Vector<>()
|
||||
);
|
||||
Email(message, db.getFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------
|
||||
Thread.sleep(60000);
|
||||
} catch (Exception ex) {
|
||||
Utils_.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
public ComponentsServer() {
|
||||
super(BugReportsDatabase.class);
|
||||
}
|
||||
@@ -41,13 +110,13 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
@Override
|
||||
protected void checkTargets(EmailMessage message_in) {
|
||||
Vector<String> checkedTargets = new Vector<>();
|
||||
for (String email: message_in.targets){
|
||||
if (db.subscribers.containsKey(email)){
|
||||
for (String email : message_in.targets) {
|
||||
if (db.subscribers.containsKey(email)) {
|
||||
Subscriber subscriber = db.subscribers.get(email);
|
||||
if (subscriber.mailOn>0){
|
||||
if (subscriber.mailOn > 0) {
|
||||
checkedTargets.add(email);
|
||||
}
|
||||
}else checkedTargets.add(email); //если почта не зарегана значит это мейл с регистрацией.
|
||||
} else checkedTargets.add(email); //если почта не зарегана значит это мейл с регистрацией.
|
||||
}
|
||||
message_in.targets = checkedTargets;
|
||||
}
|
||||
@@ -352,73 +421,4 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
protected void startAdditionalThreads() {
|
||||
backUp.start();
|
||||
}
|
||||
public static ZipFolderPass zip = new ZipFolderPass();
|
||||
public static UnzipFolderPass unzip = new UnzipFolderPass();
|
||||
public static ArchivesBackupPass backupSession = new ArchivesBackupPass();
|
||||
//-
|
||||
public static Vector<Pair<Machine, User>> storages =
|
||||
new Vector<>(Arrays.asList(
|
||||
new Pair<>(
|
||||
new Machine("titan", "dvmh.keldysh.ru", 22, MachineType.Server),
|
||||
new User("dvmuser1", "mprit_2011"))
|
||||
/*
|
||||
new Pair<>(
|
||||
new Machine("k100", "k100.kiam.ru", 22, MachineType.Server),
|
||||
new User("dvmuser1", "mprit_2011"))
|
||||
*/
|
||||
)
|
||||
);
|
||||
//-
|
||||
protected Thread backUp = new Thread(() -> {
|
||||
while (true) {
|
||||
try {
|
||||
//-------------------------------------
|
||||
Calendar rightNow = Calendar.getInstance();
|
||||
int year = rightNow.get(Calendar.YEAR);
|
||||
int month = rightNow.get(Calendar.MONTH);
|
||||
int day = rightNow.get(Calendar.DAY_OF_MONTH);
|
||||
int hour = rightNow.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = rightNow.get(Calendar.MINUTE);
|
||||
if ((hour == Global.properties.BackupHour) && (minute == Global.properties.BackupMinute)) {
|
||||
//определить имя папки с багом.
|
||||
String backUpName = year + "_" + (month + 1) + "_" + (day);
|
||||
File todayBackUp = Paths.get(Global.DataBackUpsDirectory.getAbsolutePath(), backUpName).toFile();
|
||||
File todayBackUpArchive = Paths.get(Global.DataBackUpsDirectory.getAbsolutePath(), backUpName + ".zip").toFile();
|
||||
//-
|
||||
File bugsDBBackUp = Paths.get(todayBackUp.getAbsolutePath(), db.getFile().getName()).toFile();
|
||||
File bugsArchives = Paths.get(todayBackUp.getAbsolutePath(), "Bugs.zip").toFile();
|
||||
//-
|
||||
// Чистка старых бекапов на самом сервере.
|
||||
Utils.keepNewFiles(todayBackUp.getParentFile(), 2);
|
||||
if (!todayBackUpArchive.exists()) {
|
||||
FileUtils.forceMkdir(todayBackUp);
|
||||
Files.copy(db.getFile().toPath(), bugsDBBackUp.toPath());
|
||||
//-
|
||||
zip.Do("Bugs", bugsArchives.getAbsolutePath());
|
||||
zip.Do(todayBackUp.getAbsolutePath(), todayBackUpArchive.getAbsolutePath());
|
||||
Utils_.forceDeleteWithCheck(todayBackUp);
|
||||
//-
|
||||
for (Pair<Machine, User> cred : storages) {
|
||||
backupSession.Do(cred.getKey(), cred.getValue(),
|
||||
todayBackUpArchive
|
||||
);
|
||||
}
|
||||
//bonus backup
|
||||
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
|
||||
EmailMessage message = new EmailMessage(
|
||||
"db backup",
|
||||
"копия баз данных журнала ошибок",
|
||||
new Vector<>()
|
||||
);
|
||||
Email(message, db.getFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------
|
||||
Thread.sleep(60000);
|
||||
} catch (Exception ex) {
|
||||
Utils_.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user