no message
This commit is contained in:
2
.idea/workspace.xml
generated
2
.idea/workspace.xml
generated
@@ -8,8 +8,10 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcess.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcess.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/MachineQueueSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/MachineQueueSupervisor.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -22,7 +22,10 @@ import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.*;
|
||||
import java.security.MessageDigest;
|
||||
@@ -711,9 +714,12 @@ public class Utils {
|
||||
//<editor-fold desc="создание скрипта">
|
||||
public static Process startScript(File scriptDirectory, File targetDirectory, String name, String scriptText, Map<String, String> envs) throws Exception {
|
||||
//->
|
||||
File scriptFile = Paths.get(scriptDirectory.getAbsolutePath(), name + (Global.isWindows ? ".bat" : "")).toFile();
|
||||
File scriptFile = createScript(scriptDirectory, targetDirectory, name, scriptText);
|
||||
/*
|
||||
File scriptFile=Paths.get(scriptDirectory.getAbsolutePath(), name + (Global.isWindows ? ".bat" : "")).toFile();
|
||||
FileUtils.write(scriptFile, "cd " + Utils.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
if (!scriptFile.setExecutable(true)) throw new PassException("Не удалось создать исполняемый файл для скрипта");
|
||||
*/
|
||||
//->>
|
||||
ProcessBuilder procBuilder = new ProcessBuilder(scriptFile.getAbsolutePath());
|
||||
procBuilder.directory(scriptDirectory);
|
||||
@@ -728,16 +734,12 @@ public class Utils {
|
||||
public static Process startScript(File scriptDirectory, File targetDirectory, String name, String scriptText) throws Exception {
|
||||
return startScript(scriptDirectory, targetDirectory, name, scriptText, null);
|
||||
}
|
||||
public static Process createScript(File scriptDirectory, File targetDirectory, String name, String scriptText) throws Exception {
|
||||
public static File createScript(File scriptDirectory, File targetDirectory, String name, String scriptText) throws Exception {
|
||||
//->
|
||||
File scriptFile = Paths.get(scriptDirectory.getAbsolutePath(), name + (Global.isWindows ? ".bat" : "")).toFile();
|
||||
FileUtils.write(scriptFile, "cd " + Utils.DQuotes(targetDirectory.getAbsolutePath()) + "\n" + scriptText);
|
||||
if (!scriptFile.setExecutable(true)) throw new PassException("Не удалось создать исполняемый файл для скрипта");
|
||||
//->>
|
||||
ProcessBuilder procBuilder = new ProcessBuilder(scriptFile.getAbsolutePath());
|
||||
procBuilder.directory(scriptDirectory);
|
||||
procBuilder.redirectErrorStream(true);
|
||||
return null;
|
||||
return scriptFile;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="чтение вывода процесса">
|
||||
@@ -1151,5 +1153,13 @@ public class Utils {
|
||||
//--
|
||||
return hours + " часов, " + minutes + " минут, " + seconds + " секунд";
|
||||
}
|
||||
public static boolean checkFileCreation(File file) {
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
System.out.println("Проверка " + i + " существования файла " + Utils.Brackets(file.getAbsolutePath()));
|
||||
if (file.exists()) return true;
|
||||
else sleep(1000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MachineProcess extends iDBObject {
|
||||
userWorkspace = p.userWorkspace;
|
||||
testingSystemRoot = p.testingSystemRoot;
|
||||
}
|
||||
public String getUniqueKey(){
|
||||
public String getUniqueKey() {
|
||||
Vector<String> res = new Vector<>();
|
||||
res.add(machineAddress);
|
||||
res.add(String.valueOf(machinePort));
|
||||
@@ -63,11 +63,22 @@ public class MachineProcess extends iDBObject {
|
||||
public File getWorkspace() {
|
||||
return new File(Global.MachinesDirectory, String.valueOf(id));
|
||||
}
|
||||
|
||||
public File getStartedFile() {
|
||||
return new File(getWorkspace(), Constants.STARTED);
|
||||
}
|
||||
public File getAbortedFile() {
|
||||
return new File(getWorkspace(), Constants.ABORTED);
|
||||
}
|
||||
//---
|
||||
public boolean isAborted() {
|
||||
File aborted = getAbortedFile();
|
||||
return aborted.exists();
|
||||
}
|
||||
public boolean isStarted() {
|
||||
File started = getStartedFile();
|
||||
return started.exists();
|
||||
}
|
||||
//--
|
||||
public void Start() {
|
||||
try {
|
||||
File workspace = getWorkspace();
|
||||
@@ -85,19 +96,15 @@ public class MachineProcess extends iDBObject {
|
||||
args.add(Utils.DQuotes(machinePort));
|
||||
args.add(Utils.DQuotes(userName));
|
||||
args.add(Utils.DQuotes(userPassword));
|
||||
args.add(Utils.DQuotes(userWorkspace));
|
||||
args.add(Utils.DQuotes(testingSystemRoot));
|
||||
//--
|
||||
//подготовка пакетного режима. Запустит его уже очередь.
|
||||
Utils.createScript(workspace, workspace,
|
||||
Utils.startScript(workspace, workspace,
|
||||
"start",
|
||||
"java -jar VisualSapfor.jar " + String.join(" ", args));
|
||||
//---
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
//---
|
||||
public boolean isAborted() {
|
||||
File aborted = getAbortedFile();
|
||||
return aborted.exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,23 +163,27 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Активные процессы: "+active_processes.size());
|
||||
for (String key : active_processes.keySet()){
|
||||
System.out.println("Активные процессы: " + active_processes.size());
|
||||
for (String key : active_processes.keySet()) {
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
System.out.println("Ожидающие запуск процессы: "+processes_to_start.size());
|
||||
for (String key : processes_to_start.keySet()){
|
||||
System.out.println("Ожидающие запуск процессы: " + processes_to_start.size());
|
||||
for (String key : processes_to_start.keySet()) {
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
//запуск.
|
||||
for (MachineProcess process: processes_to_start.values()){
|
||||
System.out.println("Запуск процесса "+process.getUniqueKey()+" ...");
|
||||
process.Start();
|
||||
process.state=MachineProcessState.Active;
|
||||
db.Insert(process);
|
||||
System.out.println("Выполнено");
|
||||
for (MachineProcess process : processes_to_start.values()) {
|
||||
System.out.println("Запуск процесса " + process.getUniqueKey() + " ...");
|
||||
process.Start();
|
||||
if (Utils.checkFileCreation(process.getStartedFile())) {
|
||||
process.state = MachineProcessState.Active;
|
||||
db.Insert(process);
|
||||
System.out.println("Выполнено");
|
||||
}else {
|
||||
System.out.println("Не удалось запустить процесс.");
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
@@ -76,6 +76,13 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
Print("local=" + local);
|
||||
Print("=====");
|
||||
//----
|
||||
File started = new File(supervisorHome, Constants.STARTED);
|
||||
try {
|
||||
FileUtils.writeStringToFile(started, "");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Finalize("Can not start");
|
||||
}
|
||||
}
|
||||
void CheckLocal() {
|
||||
local = false;
|
||||
@@ -125,7 +132,7 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
void Finalize(String reason){
|
||||
void Finalize(String reason) {
|
||||
File stateFile = new File(supervisorHome, Constants.ABORTED);
|
||||
try {
|
||||
FileUtils.writeStringToFile(stateFile, reason);
|
||||
@@ -447,12 +454,12 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
}
|
||||
@Override
|
||||
protected void MachineConnectionError() {
|
||||
Finalize("Количество безуспешных попыток соединения с машиной " +machine.getURL()+
|
||||
Finalize("Количество безуспешных попыток соединения с машиной " + machine.getURL() +
|
||||
" превысило 10");
|
||||
}
|
||||
@Override
|
||||
protected void ServerConnectionError(ServerCode code_in) throws Exception {
|
||||
Finalize("Не удалось выполнить команду " + code_in+ " на сервере тестирования");
|
||||
Finalize("Не удалось выполнить команду " + code_in + " на сервере тестирования");
|
||||
}
|
||||
@Override
|
||||
protected void Kill() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user