no message
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMConfiguration;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
//конфгурация тестирования ДВМ
|
||||
public class DVMConfiguration extends Configuration {
|
||||
public int c_maxtime = 40;
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
DVMConfiguration c = (DVMConfiguration) src;
|
||||
c_maxtime=c.c_maxtime;
|
||||
}
|
||||
public DVMConfiguration(DVMConfiguration src){
|
||||
this.SynchronizeFields(src);
|
||||
}
|
||||
public DVMConfiguration(){}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMConfiguration;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Tables.TableRenderers;
|
||||
import _VisualDVM.ServerObjectsCache.ConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.UI.ConfigurationFields;
|
||||
public class DVMConfigurationDBTable extends iDBTable<DVMConfiguration> {
|
||||
public DVMConfigurationDBTable() {
|
||||
super(DVMConfiguration.class);
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.DVMConfiguration;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "конфигурация тестирования DVM системы";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "конфигурации тестирования DVM системы";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(6).setRenderer(TableRenderers.RendererMultiline);
|
||||
columns.get(6).setMaxWidth(500);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"автор",
|
||||
"ядра",
|
||||
"параметры",
|
||||
"группы",
|
||||
"тестов",
|
||||
"компиляция(с)",
|
||||
"запуск(с)"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(DVMConfiguration object, int columnIndex) {
|
||||
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(object);
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.description;
|
||||
case 3:
|
||||
return object.sender_name;
|
||||
case 4:
|
||||
return object.kernels;
|
||||
case 5:
|
||||
return cache.settingsSummary;
|
||||
case 6:
|
||||
return cache.groupsSummary;
|
||||
case 7:
|
||||
return cache.getTestsCount();
|
||||
case 8:
|
||||
return object.c_maxtime;
|
||||
case 9:
|
||||
return object.maxtime;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public DBObjectDialog<DVMConfiguration, ConfigurationFields> getDialog() {
|
||||
return new DBObjectDialog<DVMConfiguration, ConfigurationFields>(ConfigurationFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 300;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 500;
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
fields.tfName.setText(Result.description);
|
||||
//------->>>>
|
||||
fields.sCompilationMaxtime.setValue(Result.c_maxtime);
|
||||
fields.sRunMaxtime.setValue(Result.maxtime);
|
||||
fields.sKernels.setValue(Result.kernels);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.c_maxtime = (int) fields.sCompilationMaxtime.getValue();
|
||||
Result.maxtime = (int) fields.sRunMaxtime.getValue();
|
||||
Result.kernels = (int) fields.sKernels.getValue();
|
||||
}
|
||||
@Override
|
||||
public void SetReadonly() {
|
||||
fields.tfName.setEnabled(false);
|
||||
fields.sCompilationMaxtime.setEnabled(false);
|
||||
fields.sRunMaxtime.setEnabled(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public boolean ShowEditObjectDialog(DBObject object) {
|
||||
return (Current.getAccount().CheckAccessRights(((DVMConfiguration) object).sender_address, null)) ? super.ShowEditObjectDialog(object) : ViewObject(object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMConfiguration;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class DVMConfigurationsMenuBar extends DataMenuBar {
|
||||
public DVMConfigurationsMenuBar() {
|
||||
super("конфигурации");
|
||||
addPasses(
|
||||
PassCode_2021.PublishConfiguration,
|
||||
|
||||
PassCode_2021.EditConfiguration,
|
||||
PassCode_2021.ShowCurrentDVMConfigurationTests,
|
||||
PassCode_2021.SaveCurrentDVMConfiguration,
|
||||
PassCode_2021.DeleteConfiguration,
|
||||
|
||||
PassCode_2021.StartSelectedDVMConfigurations
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.DVM.DVMConfiguration.UI.ConfigurationFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="467" height="163"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="5bf8c" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="18f5c" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="название"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="68a9">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="fdaa3" class="javax.swing.JTextField" binding="tfName" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="238" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="1a85a" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="макс. время компиляции, сек"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="fbc6d" class="javax.swing.JSpinner" binding="sCompilationMaxtime">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="238" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="30c43" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="макс. время выполнения, сек"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="69368" class="javax.swing.JSpinner" binding="sRunMaxtime">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="100" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="15871" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="ядра"/>
|
||||
<toolTipText value="количество ядер, задействованное при тестировани"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bd4cb" class="javax.swing.JSpinner" binding="sKernels">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="100" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,34 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMConfiguration.UI;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class ConfigurationFields implements DialogFields {
|
||||
public JTextField tfName;
|
||||
public JSpinner sCompilationMaxtime;
|
||||
public JSpinner sRunMaxtime;
|
||||
//-
|
||||
private JPanel content;
|
||||
public JSpinner sKernels;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
}
|
||||
public ConfigurationFields(){
|
||||
sCompilationMaxtime.setModel(new SpinnerNumberModel(40,
|
||||
5, 3600, 1
|
||||
));
|
||||
sRunMaxtime.setModel(new SpinnerNumberModel(40,
|
||||
5, 3600, 1
|
||||
));
|
||||
sKernels.setModel(new SpinnerNumberModel(1, 1,
|
||||
Constants.testingMaxKernels,
|
||||
1));
|
||||
}
|
||||
}
|
||||
121
src/_VisualDVM/TestingSystem/DVM/DVMPackage/DVMPackage.java
Normal file
121
src/_VisualDVM/TestingSystem/DVM/DVMPackage/DVMPackage.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMPackage;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.ServerObjectsCache.DVMConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.GlobalData.Compiler.Compiler;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.TasksPackageState;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackage.TestingPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
public class DVMPackage extends TestingPackage<DVMPackage_json> {
|
||||
//---
|
||||
public String machine_name = "";
|
||||
public String machine_address = "";
|
||||
public int machine_port = 22;
|
||||
//---
|
||||
public String user_name = "";
|
||||
public String user_password;
|
||||
public String user_workspace;
|
||||
//---
|
||||
public DVMPackage() {
|
||||
}
|
||||
public DVMPackage(Account account,
|
||||
Machine machine,
|
||||
User user,
|
||||
Compiler compiler,
|
||||
Vector<DVMConfiguration> configurations,
|
||||
int neeedsEmail_in) {
|
||||
id = CommonConstants.Nan;
|
||||
//-
|
||||
sender_name = account.name;
|
||||
sender_address = account.email;
|
||||
//-
|
||||
machine_name = machine.name;
|
||||
machine_address = machine.address;
|
||||
machine_port = machine.port;
|
||||
//-
|
||||
user_name = user.login;
|
||||
user_password = user.password;
|
||||
user_workspace = user.workspace;
|
||||
//-
|
||||
drv = compiler.call_command;
|
||||
version = compiler.getVersionInfo();
|
||||
//-
|
||||
needsEmail = neeedsEmail_in;
|
||||
//--
|
||||
state = TasksPackageState.Queued;
|
||||
//--
|
||||
for (DVMConfiguration configuration : configurations)
|
||||
kernels = Math.max(configuration.kernels, kernels);
|
||||
//-
|
||||
tasksCount = 0;
|
||||
Vector<DVMCompilationTask> compilationTasks = new Vector<DVMCompilationTask>();
|
||||
for (DVMConfiguration configuration : configurations) {
|
||||
DVMConfigurationCache cache = (DVMConfigurationCache) VisualCaches.GetCache(configuration);
|
||||
for (Group group : cache.getGroups()) {
|
||||
for (Test test : cache.getGroupTests(group)) {
|
||||
for (DVMSettings dvmSettings : cache.getSettings()) {
|
||||
DVMCompilationTask compilationTask = new DVMCompilationTask(configuration, dvmSettings, group, test, kernels);
|
||||
compilationTasks.add(compilationTask);
|
||||
tasksCount += compilationTask.runTasks.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package_json = new DVMPackage_json(compilationTasks);
|
||||
saveConfigurationsAsJson(configurations);
|
||||
}
|
||||
@Override
|
||||
public Class getJsonClass() {
|
||||
return DVMPackage_json.class;
|
||||
}
|
||||
@Override
|
||||
public File getHomeDirectory() {
|
||||
return Global.DVMPackagesDirectory;
|
||||
}
|
||||
public DVMPackage(DVMPackage p) {
|
||||
super(p);
|
||||
this.SynchronizeFields(p);
|
||||
}
|
||||
//---
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
DVMPackage tasksPackage = (DVMPackage) src;
|
||||
machine_name = tasksPackage.machine_name;
|
||||
machine_address = tasksPackage.machine_address;
|
||||
machine_port = tasksPackage.machine_port;
|
||||
user_name = tasksPackage.user_name;
|
||||
user_workspace = tasksPackage.user_workspace;
|
||||
user_password = tasksPackage.user_password;
|
||||
}
|
||||
public Machine getMachine() {
|
||||
return new Machine(machine_name, machine_address, machine_port, MachineType.Server);
|
||||
}
|
||||
public User getUser() {
|
||||
return new User(user_name, user_password, user_workspace);
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return (!DVMPackageDBTable.filterMyOnly || Current.getAccount().email.equals(sender_address)) &&
|
||||
(!DVMPackageDBTable.filterActive || state.isActive());
|
||||
}
|
||||
@Override
|
||||
public void checkFinishState() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMPackage;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.ServerObjectsCache.PackageCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
|
||||
import static Common.Visual.Tables.TableRenderers.*;
|
||||
public class DVMPackageDBTable extends iDBTable<DVMPackage> {
|
||||
public static boolean filterMyOnly = false;
|
||||
public static boolean filterActive = false;
|
||||
public DVMPackageDBTable() {
|
||||
super(DVMPackage.class);
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.DVMPackage;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "пакет задач DVM";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "пакеты задач DVM";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(6).setRenderer(RendererMultiline);
|
||||
// columns.get(7).setRenderer(RendererMultiline);
|
||||
columns.get(9).setRenderer(RendererProgress);
|
||||
columns.get(10).setRenderer(RendererDate);
|
||||
columns.get(11).setRenderer(RendererDate);
|
||||
columns.get(12).setRenderer(RendererStatusEnum);
|
||||
}
|
||||
@Override
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
super.ShowCurrentObject();
|
||||
//--
|
||||
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(getCurrent());
|
||||
UI.getMainWindow().getTestingWindow().DropTestRunTasksComparison();
|
||||
//--
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
super.ShowNoCurrentObject();
|
||||
Global.testingServer.db.dvmRunTasks.ShowNoPackage();
|
||||
UI.getMainWindow().getTestingWindow().DropTestRunTasksComparison();
|
||||
}
|
||||
@Override
|
||||
public void MouseAction2() throws Exception {
|
||||
Pass_2021.passes.get(PassCode_2021.DownloadDVMPackage).Do();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"Автор",
|
||||
"Машина",
|
||||
"Пользователь",
|
||||
"DVM",
|
||||
"Конфигурации",
|
||||
"Задач",
|
||||
"Ядер",
|
||||
"Прогресс",
|
||||
"Начало",
|
||||
"Изменено",
|
||||
"Статус"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(DVMPackage object, int columnIndex) {
|
||||
PackageCache cache = (PackageCache) VisualCaches.GetCache(object);
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.sender_name;
|
||||
case 3:
|
||||
return object.machine_address + ":" + object.machine_port;
|
||||
case 4:
|
||||
return object.user_name;
|
||||
case 5:
|
||||
return object.version;
|
||||
case 6:
|
||||
return cache.getConfigurationsDescriptions();
|
||||
case 7:
|
||||
return object.tasksCount;
|
||||
case 8:
|
||||
return object.kernels;
|
||||
case 9:
|
||||
return object.progress;
|
||||
case 10:
|
||||
return new Date(object.StartDate);
|
||||
case 11:
|
||||
return new Date(object.ChangeDate);
|
||||
case 12:
|
||||
return object.state;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Comparator<DVMPackage> getComparator() {
|
||||
return new Comparator<DVMPackage>() {
|
||||
@Override
|
||||
public int compare(DVMPackage o1, DVMPackage o2) {
|
||||
return o2.id - o1.id;
|
||||
}
|
||||
};
|
||||
// return Comparator.comparingInt(o -> o.).reversed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMRunTask;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class DVMPackage_json implements Serializable {
|
||||
@Expose
|
||||
public int max_task_id = 0;
|
||||
@Expose
|
||||
public List<DVMCompilationTask> compilationTasks = new Vector<>();
|
||||
public int getMaxTaskId() {
|
||||
return max_task_id++;
|
||||
}
|
||||
public DVMPackage_json(){}
|
||||
public DVMPackage_json(List<DVMCompilationTask> tasks){
|
||||
for (DVMCompilationTask compilationTask : tasks) {
|
||||
compilationTask.id = getMaxTaskId();
|
||||
//-
|
||||
for (DVMRunTask runTask : compilationTask.runTasks) {
|
||||
runTask.id = getMaxTaskId();
|
||||
runTask.dvmcompilationtask_id = compilationTask.id;
|
||||
}
|
||||
}
|
||||
compilationTasks.addAll(tasks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMPackage;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Common.Visual.Controls.MenuBarButton;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
public class DVMPackagesBar extends DataMenuBar {
|
||||
public DVMPackagesBar() {
|
||||
super("пакеты задач DVM");
|
||||
addPasses(PassCode_2021.SynchronizeTests);
|
||||
addSeparator();
|
||||
addPasses(PassCode_2021.AbortDVMPackage );
|
||||
addSeparator();
|
||||
addPasses(PassCode_2021.DownloadDVMPackage,
|
||||
PassCode_2021.ExportDVMPackageToExcel,
|
||||
PassCode_2021.DeleteDVMPackage);
|
||||
add(new JSeparator());
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setText("Свои");
|
||||
setToolTipText("Отображать только пакеты тестов авторства пользователя");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
DVMPackageDBTable.filterMyOnly = !DVMPackageDBTable.filterMyOnly;
|
||||
Mark();
|
||||
Global.testingServer.db.dvmPackages.ShowUI();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(DVMPackageDBTable.filterMyOnly ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setText("Активные");
|
||||
setToolTipText("Отображать только активные пакеты тестов");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
DVMPackageDBTable.filterActive = !DVMPackageDBTable.filterActive;
|
||||
Mark();
|
||||
Global.testingServer.db.dvmPackages.ShowUI();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(DVMPackageDBTable.filterActive ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMSettings;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Settings;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.util.Vector;
|
||||
public class DVMSettings extends Settings {
|
||||
//todo.хранить флаги и окружение в json чтобы можно было в форме их видеть.
|
||||
public String environments="";
|
||||
@Description("DEFAULT 0")
|
||||
public int Is_DVM_STAT= 0; //флаг вмест usr par, которые не использовались.
|
||||
// public String usr_par = "";
|
||||
//---
|
||||
public int cube = 0; //
|
||||
public int max_proc_count = 4;
|
||||
public int min_dim_proc_count = 1;
|
||||
public int max_dim_proc_count = 4;
|
||||
//
|
||||
public DVMSettings(){}
|
||||
public DVMSettings(DVMSettings src){
|
||||
this.SynchronizeFields(src);
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
DVMSettings c = (DVMSettings) src;
|
||||
environments=c.environments;
|
||||
Is_DVM_STAT = c.Is_DVM_STAT;
|
||||
// usr_par=c.usr_par;
|
||||
//-
|
||||
cube= c.cube;
|
||||
max_proc_count=c.max_proc_count;
|
||||
min_dim_proc_count=c.min_dim_proc_count;
|
||||
max_dim_proc_count=c.max_dim_proc_count;
|
||||
}
|
||||
public String printUsrPar(){
|
||||
return "Is_DVM_STAT="+Is_DVM_STAT;
|
||||
}
|
||||
public Vector<String> getMatrixes(int testDim) {
|
||||
Vector<Vector<Integer>> res_ = new Vector<>();
|
||||
Vector<String> res = new Vector<>();
|
||||
if ((max_proc_count==0) || (min_dim_proc_count == 0 && max_dim_proc_count == 0)) {
|
||||
res.add("");
|
||||
} else {
|
||||
if (testDim > 0) {
|
||||
Vector<String> min_border = new Vector<>();
|
||||
Vector<String> max_border = new Vector<>();
|
||||
for (int i = 1; i <= testDim; ++i) {
|
||||
min_border.add(String.valueOf(min_dim_proc_count));
|
||||
max_border.add(String.valueOf(max_dim_proc_count));
|
||||
}
|
||||
Vector<Integer> from = RunConfiguration.getBounds(String.join(" ", min_border));
|
||||
Vector<Integer> to = RunConfiguration.getBounds(String.join(" ", max_border));
|
||||
if (from.size() != to.size()) {
|
||||
return res;
|
||||
}
|
||||
if (from.size() != testDim) {
|
||||
return res;
|
||||
}
|
||||
//1 стадия. заполнение.
|
||||
for (int j = from.get(0); j <= to.get(0); ++j) {
|
||||
Vector<Integer> m = new Vector<>();
|
||||
res_.add(m);
|
||||
m.add(j);
|
||||
}
|
||||
//---
|
||||
if (testDim > 1) RunConfiguration.gen_rec(from, to, res_, 1, testDim, cube == 1);
|
||||
for (Vector<Integer> m : res_) {
|
||||
Vector<String> ms = new Vector<>();
|
||||
int proc = 1;
|
||||
for (int i : m) {
|
||||
ms.add(String.valueOf(i));
|
||||
proc *= i;
|
||||
}
|
||||
if (proc <= max_proc_count)
|
||||
res.add(String.join(" ", ms));
|
||||
}
|
||||
} else res.add("");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public String getParamsText() {
|
||||
return "Is_DVM_STAT="+Is_DVM_STAT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMSettings;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMSettings.UI.DVMSettingsFields;
|
||||
public class DVMSettingsDBTable extends iDBTable<DVMSettings> {
|
||||
public DVMSettingsDBTable() {
|
||||
super(DVMSettings.class);
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.DVMSettings;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "параметры тестирования DVM системы";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "параметры тестирования DVM системы";
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"автор",
|
||||
"флаги",
|
||||
"окружение",
|
||||
"usr.par",
|
||||
"куб",
|
||||
"max",
|
||||
"min dim",
|
||||
"max dim"
|
||||
};
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
public Object getFieldAt(DVMSettings object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.description;
|
||||
case 3:
|
||||
return object.sender_name;
|
||||
case 4:
|
||||
return object.flags;
|
||||
case 5:
|
||||
return object.environments;
|
||||
case 6:
|
||||
return object.printUsrPar();
|
||||
case 7:
|
||||
return object.cube;
|
||||
case 8:
|
||||
return object.max_proc_count;
|
||||
case 9:
|
||||
return object.min_dim_proc_count;
|
||||
case 10:
|
||||
return object.max_dim_proc_count;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//-
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
/*
|
||||
columns.get(5).setRenderer(TableRenderers.RendererMultiline);
|
||||
columns.get(5).setMaxWidth(500);
|
||||
columns.get(7).setRenderer(TableRenderers.RendererMultiline);
|
||||
columns.get(8).setRenderer(TableRenderers.RendererMultiline);
|
||||
columns.get(15).setRenderer(TableRenderers.RendererMultiline);
|
||||
*/
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public DBObjectDialog<DVMSettings, DVMSettingsFields> getDialog() {
|
||||
return new DBObjectDialog<DVMSettings, DVMSettingsFields>(DVMSettingsFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 400;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 800;
|
||||
}
|
||||
@Override
|
||||
public void validateFields() {
|
||||
int min = (int) fields.sMinDimProc.getValue();
|
||||
int max = (int) fields.sMaxDimProc.getValue();
|
||||
if (max < min)
|
||||
Log.Writeln_("Некорректный диапазон размерностей: максимум меньше минимума");
|
||||
if ((min == 0) && (max != 0) || (min != 0) && (max == 0))
|
||||
Log.Writeln_("Некорректный диапазон размерностей. " +
|
||||
"'0' допускается только одновременно на обеих границах,\n" +
|
||||
"и подразумевает единственный запуск без решётки");
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
fields.tfName.setText(Result.description);
|
||||
//------->>>
|
||||
fields.tfFlags.setText(Result.flags);
|
||||
fields.tfEnvironments.setText(Result.environments);
|
||||
//------->>>
|
||||
fields.sMinDimProc.setValue(Result.min_dim_proc_count);
|
||||
fields.sMaxDimProc.setValue(Result.max_dim_proc_count);
|
||||
fields.cbCube.setSelected(Result.cube == 1);
|
||||
//-
|
||||
fields.sMaxProc.setValue(Result.max_proc_count);
|
||||
fields.cbDvmStat.setSelected(Result.Is_DVM_STAT!=0);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.min_dim_proc_count = (int) fields.sMinDimProc.getValue();
|
||||
Result.max_dim_proc_count = (int) fields.sMaxDimProc.getValue();
|
||||
Result.cube = fields.cbCube.isSelected() ? 1 : 0;
|
||||
Result.max_proc_count = (int) fields.sMaxProc.getValue();
|
||||
Result.flags = fields.tfFlags.getText();
|
||||
Result.environments = fields.tfEnvironments.getText();
|
||||
Result.Is_DVM_STAT = fields.cbDvmStat.isSelected()?1:0;
|
||||
}
|
||||
@Override
|
||||
public void SetReadonly() {
|
||||
fields.tfName.setEnabled(false);
|
||||
fields.sMinDimProc.setEnabled(false);
|
||||
fields.sMaxDimProc.setEnabled(false);
|
||||
fields.cbCube.setEnabled(false);
|
||||
fields.sMaxProc.setEnabled(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public boolean ShowEditObjectDialog(DBObject object) {
|
||||
return (Current.getAccount().CheckAccessRights(((DVMSettings) object).sender_address, null)) ? super.ShowEditObjectDialog(object) : ViewObject(object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMSettings.UI;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class DVMSettingsBar extends DataMenuBar {
|
||||
public DVMSettingsBar() {
|
||||
super("параметры тестированя",
|
||||
PassCode_2021.PublishDVMSettings,
|
||||
PassCode_2021.CloneDVMSettings,
|
||||
PassCode_2021.EditDVMSettings,
|
||||
PassCode_2021.DeleteDVMSettings
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.DVM.DVMSettings.UI.DVMSettingsFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="777" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="e9baf" layout-manager="GridLayoutManager" row-count="9" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="8f4d9" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="название"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="2176d">
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="c61a7" class="javax.swing.JTextField" binding="tfName" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="238" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="a1d86" class="javax.swing.JSpinner" binding="sMinDimProc">
|
||||
<constraints>
|
||||
<grid row="5" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="100" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="deae5" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="мин. число процессоров по измерению"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="61ffc" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="макс. число процессоров по измерению"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="380de" class="javax.swing.JSpinner" binding="sMaxDimProc">
|
||||
<constraints>
|
||||
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="100" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="9b010" class="javax.swing.JCheckBox" binding="cbCube">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<horizontalAlignment value="0"/>
|
||||
<icon value="icons/NotPick.png"/>
|
||||
<selectedIcon value="icons/Pick.png"/>
|
||||
<text value="кубические решётки"/>
|
||||
<toolTipText value="матрица с одинаковым размером измерений"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bd5c7" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="макс. число процессоров"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ad38a" class="javax.swing.JSpinner" binding="sMaxProc">
|
||||
<constraints>
|
||||
<grid row="4" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="100" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="4d47b" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="флаги"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="45943" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="окружение"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="decc3" class="javax.swing.JTextField" binding="tfFlags">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="400" height="30"/>
|
||||
<preferred-size width="400" height="30"/>
|
||||
<maximum-size width="400" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
<font size="10"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f6927" class="javax.swing.JTextField" binding="tfEnvironments">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="400" height="30"/>
|
||||
<preferred-size width="400" height="30"/>
|
||||
<maximum-size width="400" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
<font size="10"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="265bb" class="javax.swing.JButton" binding="bAddFlags">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<borderPainted value="false"/>
|
||||
<icon value="icons/Menu/Regions.png"/>
|
||||
<maximumSize width="30" height="30"/>
|
||||
<minimumSize width="30" height="30"/>
|
||||
<preferredSize width="30" height="30"/>
|
||||
<text value=""/>
|
||||
<toolTipText value="Редактировать флаги"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="77de1" class="javax.swing.JButton" binding="bAddEnvironments">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<borderPainted value="false"/>
|
||||
<icon value="icons/Menu/Regions.png"/>
|
||||
<maximumSize width="30" height="30"/>
|
||||
<minimumSize width="30" height="30"/>
|
||||
<preferredSize width="30" height="30"/>
|
||||
<text value=""/>
|
||||
<toolTipText value="Добавить набор переменных окружения"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7682" class="javax.swing.JButton" binding="bDeleteFlags">
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<borderPainted value="false"/>
|
||||
<icon value="icons/Delete.png"/>
|
||||
<maximumSize width="30" height="30"/>
|
||||
<minimumSize width="30" height="30"/>
|
||||
<preferredSize width="30" height="30"/>
|
||||
<text value=""/>
|
||||
<toolTipText value="Удалить флаги"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6c384" class="javax.swing.JButton" binding="bDeleteEnvironment">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<borderPainted value="false"/>
|
||||
<icon value="icons/Delete.png"/>
|
||||
<maximumSize width="30" height="30"/>
|
||||
<minimumSize width="30" height="30"/>
|
||||
<preferredSize width="30" height="30"/>
|
||||
<text value=""/>
|
||||
<toolTipText value="Удалить переменную окружения"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3f04c" class="javax.swing.JCheckBox" binding="cbDvmStat">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<horizontalAlignment value="0"/>
|
||||
<icon value="icons/NotPick.png"/>
|
||||
<selectedIcon value="icons/Pick.png"/>
|
||||
<text value="Is_DVM_STAT"/>
|
||||
<toolTipText value="сбор статистики DVM после запуска"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,68 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMSettings.UI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class DVMSettingsFields implements DialogFields {
|
||||
private JPanel content;
|
||||
public JTextField tfName;
|
||||
public JSpinner sMinDimProc;
|
||||
public JSpinner sMaxDimProc;
|
||||
public JSpinner sMaxProc;
|
||||
public JCheckBox cbCube;
|
||||
public JTextField tfFlags;
|
||||
public JTextField tfEnvironments;
|
||||
private JButton bAddFlags;
|
||||
private JButton bAddEnvironments;
|
||||
private JButton bDeleteFlags;
|
||||
private JButton bDeleteEnvironment;
|
||||
public JCheckBox cbDvmStat;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
}
|
||||
public DVMSettingsFields(){
|
||||
sMinDimProc.setModel(new SpinnerNumberModel(1, 0, 128, 1));
|
||||
sMaxDimProc.setModel(new SpinnerNumberModel(1, 0, 128, 1));
|
||||
sMaxProc.setModel(new SpinnerNumberModel(0, 0, 128, 1));
|
||||
bAddFlags.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021 pass = Pass_2021.passes.get(PassCode_2021.PickCompilerOptions);
|
||||
if (pass.Do(Current.getCompiler())) {
|
||||
tfFlags.setText((String)pass.target);
|
||||
}
|
||||
}
|
||||
});
|
||||
bAddEnvironments.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021 pass = Pass_2021.passes.get(PassCode_2021.PickCompilerEnvironmentsForTesting);
|
||||
if (pass.Do(Current.getCompiler()))
|
||||
tfEnvironments.setText((String)pass.target);
|
||||
}
|
||||
});
|
||||
bDeleteFlags.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfFlags.setText("");
|
||||
}
|
||||
});
|
||||
bDeleteEnvironment.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfEnvironments.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMTasks;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class DVMCompilationTask extends DVMTask {
|
||||
@Expose
|
||||
public List<DVMRunTask> runTasks = new Vector<>();
|
||||
//-
|
||||
public DVMCompilationTask() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public Vector<String> pack(Object arg) {
|
||||
Vector<String> res = new Vector<>();
|
||||
res.add(String.valueOf(id)); //1
|
||||
res.add(String.valueOf(maxtime)); //2
|
||||
res.add(String.valueOf(test_id)); //3
|
||||
res.add(arg.toString().replace("\n", "|")); //4
|
||||
return res;
|
||||
}
|
||||
//--
|
||||
public static String checkFlags(String flags_in) {
|
||||
if (!flags_in.contains("-shared-dvm")) {
|
||||
if (flags_in.isEmpty())
|
||||
return "-shared-dvm";
|
||||
else return flags_in + " -shared-dvm";
|
||||
} else
|
||||
return flags_in;
|
||||
}
|
||||
public static String checkEnvironments(String environmentsSet_in) {
|
||||
if (!environmentsSet_in.contains("DVMH_NO_DIRECT_COPY")) {
|
||||
if (environmentsSet_in.isEmpty())
|
||||
return "DVMH_NO_DIRECT_COPY=" + CommonUtils.DQuotes("1");
|
||||
else
|
||||
return environmentsSet_in + " " + "DVMH_NO_DIRECT_COPY=" + CommonUtils.DQuotes("1");
|
||||
} else
|
||||
return environmentsSet_in;
|
||||
}
|
||||
//--
|
||||
public DVMCompilationTask(DVMConfiguration configuration, DVMSettings dvmSettings, Group group, Test test, int kernels_in){
|
||||
super (configuration, group, test,checkFlags(dvmSettings.flags));
|
||||
Vector<String> matrixes = dvmSettings.getMatrixes(test.max_dim);
|
||||
String checkedEnvironments = checkEnvironments(dvmSettings.environments);
|
||||
if (dvmSettings.flags.trim().equalsIgnoreCase("-s")) {
|
||||
runTasks.add(new DVMRunTask(
|
||||
configuration,
|
||||
dvmSettings,
|
||||
group,
|
||||
test,
|
||||
"",
|
||||
flags,
|
||||
checkedEnvironments,
|
||||
kernels_in
|
||||
));
|
||||
} else
|
||||
for (String matrix : matrixes) {
|
||||
runTasks.add(new DVMRunTask(
|
||||
configuration,
|
||||
dvmSettings,
|
||||
group,
|
||||
test,
|
||||
matrix,
|
||||
flags,
|
||||
checkedEnvironments,
|
||||
kernels_in));
|
||||
}
|
||||
}
|
||||
}
|
||||
136
src/_VisualDVM/TestingSystem/DVM/DVMTasks/DVMRunTask.java
Normal file
136
src/_VisualDVM/TestingSystem/DVM/DVMTasks/DVMRunTask.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMTasks;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.Test.TestType;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Vector;
|
||||
public class DVMRunTask extends DVMTask {
|
||||
@Expose
|
||||
public int dvmcompilationtask_id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public String matrix = "";
|
||||
@Expose
|
||||
public String args = "";
|
||||
@Expose
|
||||
public double CleanTime = 0.0;
|
||||
@Expose
|
||||
public int progress = 0;
|
||||
@Expose
|
||||
public int cube = 1;
|
||||
@Expose
|
||||
public int min_dim = 1;
|
||||
@Expose
|
||||
public int max_dim = 1;
|
||||
@Expose
|
||||
public String environments = "";
|
||||
@Expose
|
||||
public String usr_par = "";
|
||||
@Expose
|
||||
public int compilation_maxtime = 40;
|
||||
@Expose
|
||||
public TaskState compilation_state = TaskState.Waiting;
|
||||
@Expose
|
||||
public double compilation_time = 0.0;
|
||||
public DVMRunTask(DVMConfiguration configuration, DVMSettings settings,
|
||||
Group group, Test test,
|
||||
String matrix_in, String flags_in,
|
||||
String environments_in,
|
||||
int kernels_in
|
||||
) {
|
||||
super(configuration, group, test, flags_in);
|
||||
//--------------------------
|
||||
//инфа о компиляции.
|
||||
compilation_maxtime = configuration.c_maxtime;
|
||||
compilation_state = TaskState.Waiting;
|
||||
//инфа о запуске
|
||||
cube = settings.cube;
|
||||
min_dim = settings.max_dim_proc_count;
|
||||
max_dim = settings.max_dim_proc_count;
|
||||
maxtime = configuration.maxtime;
|
||||
environments = environments_in;
|
||||
usr_par = settings.getParamsText();
|
||||
args = test.args;
|
||||
//---------
|
||||
matrix = matrix_in;
|
||||
kernels = (test_type == TestType.Performance) ? kernels_in :
|
||||
Math.min(Utils.getMatrixProcessors(matrix), kernels_in);
|
||||
}
|
||||
public DVMRunTask() {
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
DVMRunTask rt = (DVMRunTask) src;
|
||||
dvmcompilationtask_id = rt.dvmcompilationtask_id;
|
||||
matrix = rt.matrix;
|
||||
CleanTime = rt.CleanTime;
|
||||
progress = rt.progress;
|
||||
language = rt.language;
|
||||
cube = rt.cube;
|
||||
min_dim = rt.min_dim;
|
||||
max_dim = rt.max_dim;
|
||||
maxtime = rt.maxtime;
|
||||
environments = rt.environments;
|
||||
usr_par = rt.usr_par;
|
||||
compilation_maxtime = rt.compilation_maxtime;
|
||||
compilation_state = rt.compilation_state;
|
||||
compilation_time = rt.compilation_time;
|
||||
args = rt.args;
|
||||
}
|
||||
public DVMRunTask(DVMRunTask src) {
|
||||
this.SynchronizeFields(src);
|
||||
}
|
||||
//-
|
||||
@Override
|
||||
public Vector<String> pack(Object arg) {
|
||||
Vector<String> res = new Vector<>();
|
||||
res.add(String.valueOf(id)); //1
|
||||
res.add(String.valueOf(maxtime)); //2
|
||||
res.add(String.valueOf(dvmcompilationtask_id)); //3
|
||||
res.add(matrix); //4
|
||||
res.add(environments); //5
|
||||
res.add(usr_par.replace("\n", "|")); //6
|
||||
res.add(args); //7
|
||||
res.add(String.valueOf(kernels)); //8
|
||||
return res;
|
||||
}
|
||||
public String getEnvironments() {
|
||||
return environments.replace("\n", ";");
|
||||
}
|
||||
public String getUsrPar() {
|
||||
return usr_par.replace("\n", ";");
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Global.testingServer.db.dvmRunTasks.applyFilters(this);
|
||||
}
|
||||
public File getCompilationTaskWorkspace() {
|
||||
return Paths.get(
|
||||
Global.DVMPackagesDirectory.getAbsolutePath(),
|
||||
String.valueOf(dvm_package_id),
|
||||
"results",
|
||||
String.valueOf(dvmcompilationtask_id)
|
||||
).toFile();
|
||||
}
|
||||
public String getCompilationOutput() {
|
||||
return getResultFile(new File(getCompilationTaskWorkspace(),Constants.out_file));
|
||||
}
|
||||
public String getCompilationErrors() {
|
||||
return getResultFile(new File(getCompilationTaskWorkspace(),Constants.err_file));
|
||||
}
|
||||
public String getStatistic() {
|
||||
return getResultFile(new File(getLocalWorkspace(), Constants.statistic + ".txt"));
|
||||
}
|
||||
}
|
||||
//--
|
||||
@@ -0,0 +1,9 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMTasks;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class DVMRunTasksBar extends DataMenuBar {
|
||||
public DVMRunTasksBar() {
|
||||
super("задачи",
|
||||
PassCode_2021.CompareDVMRunTasks, PassCode_2021.DownloadTaskTest);
|
||||
}
|
||||
}
|
||||
165
src/_VisualDVM/TestingSystem/DVM/DVMTasks/DVMRunTasksSet.java
Normal file
165
src/_VisualDVM/TestingSystem/DVM/DVMTasks/DVMRunTasksSet.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMTasks;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.DBObjectFilter;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Visual.DataSetFilter;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import static Common.Visual.Tables.TableRenderers.RendererProgress;
|
||||
import static Common.Visual.Tables.TableRenderers.RendererStatusEnum;
|
||||
public class DVMRunTasksSet extends DataSet<Integer, DVMRunTask> {
|
||||
//todo обобщить бы наличие фильтров для всех таблиц.
|
||||
DVMPackage target;
|
||||
@Override
|
||||
protected void createFilters() {
|
||||
filters.add(new DataSetFilter<DVMRunTask>("Компиляция", this) {
|
||||
@Override
|
||||
public void fill() {
|
||||
for (TaskState state : TaskState.values()) {
|
||||
if (state.isVisible()) {
|
||||
field_filters.add(new DBObjectFilter<DVMRunTask>(dataSet, state.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(DVMRunTask object) {
|
||||
return object.compilation_state.equals(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
filters.add(new DataSetFilter<DVMRunTask>("Запуск", this) {
|
||||
@Override
|
||||
public void fill() {
|
||||
for (TaskState state : TaskState.values()) {
|
||||
if (state.isVisible()) {
|
||||
field_filters.add(new DBObjectFilter<DVMRunTask>(dataSet, state.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(DVMRunTask object) {
|
||||
return object.state.equals(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public DVMRunTasksSet() {
|
||||
super(Integer.class, DVMRunTask.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "задача";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "задачи";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(5).setRenderer(RendererStatusEnum);
|
||||
columns.get(6).setRenderer(RendererStatusEnum);
|
||||
columns.get(13).setRenderer(RendererProgress);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"Тест",
|
||||
"Язык",
|
||||
"Флаги",
|
||||
"Компиляция",
|
||||
"Запуск",
|
||||
"Матрица",
|
||||
"Окружение",
|
||||
"usr.par",
|
||||
"Время компиляции (с)",
|
||||
"Время запуска (с)",
|
||||
"Чистое время (с)",
|
||||
"Прогресс",
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(DVMRunTask object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.test_description;
|
||||
case 3:
|
||||
return object.language;
|
||||
case 4:
|
||||
return object.flags;
|
||||
case 5:
|
||||
return object.compilation_state;
|
||||
case 6:
|
||||
return object.state;
|
||||
case 7:
|
||||
return object.matrix;
|
||||
case 8:
|
||||
return object.getEnvironments();
|
||||
case 9:
|
||||
return object.getUsrPar();
|
||||
case 10:
|
||||
return object.compilation_time;
|
||||
case 11:
|
||||
return object.Time;
|
||||
case 12:
|
||||
return object.CleanTime;
|
||||
case 13:
|
||||
return object.progress;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.DVMRunTask;
|
||||
}
|
||||
public void ShowDVMPackage(DVMPackage dvmPackage) {
|
||||
target = dvmPackage;
|
||||
ClearUI();
|
||||
Data.clear();
|
||||
if (dvmPackage.package_json == null) {
|
||||
if (dvmPackage.getJsonFile().exists()) {
|
||||
try {
|
||||
dvmPackage.readJson();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dvmPackage.package_json != null) {
|
||||
for (DVMCompilationTask compilationTask : dvmPackage.package_json.compilationTasks) {
|
||||
for (DVMRunTask runTask : compilationTask.runTasks) {
|
||||
Data.put(runTask.id, runTask);
|
||||
}
|
||||
}
|
||||
ShowUI();
|
||||
}
|
||||
}
|
||||
public void ShowNoPackage() {
|
||||
ClearUI();
|
||||
Data.clear();
|
||||
target = null;
|
||||
}
|
||||
@Override
|
||||
public Comparator<DVMRunTask> getComparator() {
|
||||
return new Comparator<DVMRunTask>() {
|
||||
@Override
|
||||
public int compare(DVMRunTask o1, DVMRunTask o2) {
|
||||
return o1.state.ordinal() - o2.state.ordinal();
|
||||
}
|
||||
};
|
||||
// return Comparator.comparingInt(o -> o.).reversed();
|
||||
}
|
||||
}
|
||||
107
src/_VisualDVM/TestingSystem/DVM/DVMTasks/DVMTask.java
Normal file
107
src/_VisualDVM/TestingSystem/DVM/DVMTasks/DVMTask.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package _VisualDVM.TestingSystem.DVM.DVMTasks;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.Test.TestType;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Vector;
|
||||
public class DVMTask extends iDBObject {
|
||||
@Expose
|
||||
public int dvm_package_id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public int group_id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public String group_description = "";
|
||||
@Expose
|
||||
public int test_id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public String test_description = "";
|
||||
@Expose
|
||||
public LanguageName language = LanguageName.fortran;
|
||||
@Expose
|
||||
public String flags = "";
|
||||
@Expose
|
||||
public int kernels = 1;
|
||||
@Expose
|
||||
public TaskState state = TaskState.Inactive;
|
||||
@Expose
|
||||
public int maxtime = 40;
|
||||
@Expose
|
||||
public TestType test_type = TestType.Default;
|
||||
//результаты-------------------------------
|
||||
@Expose
|
||||
public double Time; //время выполнения.
|
||||
//------------------------------------------------------
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
DVMTask t = (DVMTask) src;
|
||||
group_id = t.group_id;
|
||||
group_description = t.group_description;
|
||||
test_id = t.test_id;
|
||||
test_description = t.test_description;
|
||||
language = t.language;
|
||||
flags = t.flags;
|
||||
kernels = t.kernels;
|
||||
state = t.state;
|
||||
maxtime = t.maxtime;
|
||||
test_type = t.test_type;
|
||||
Time = t.Time;
|
||||
}
|
||||
public DVMTask(DVMTask src) {
|
||||
this.SynchronizeFields(src);
|
||||
}
|
||||
public DVMTask() {
|
||||
}
|
||||
public DVMTask(DVMConfiguration configuration,
|
||||
Group group, Test test, String flags_in) {
|
||||
group_id = group.id;
|
||||
test_id = test.id;
|
||||
group_description = group.description;
|
||||
test_description = test.description;
|
||||
test_type = group.type;
|
||||
language = group.language;
|
||||
flags = flags_in;
|
||||
}
|
||||
public File getLocalWorkspace() {
|
||||
return
|
||||
Paths.get(Global.DVMPackagesDirectory.getAbsolutePath(),
|
||||
String.valueOf(dvm_package_id),
|
||||
"results",
|
||||
String.valueOf(id)).toFile();
|
||||
}
|
||||
public Vector<String> pack(Object arg) {
|
||||
return null;
|
||||
}
|
||||
public String getResultFile(File resultFile) {
|
||||
String res = "";
|
||||
if (dvm_package_id == CommonConstants.Nan) res = "задача ещё не выполнялась";
|
||||
else {
|
||||
if (resultFile.exists()) {
|
||||
try {
|
||||
res = FileUtils.readFileToString(resultFile);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else res = "не существует";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public String getOutput() {
|
||||
return getResultFile(new File(getLocalWorkspace(), Constants.out_file));
|
||||
}
|
||||
public String getErrors() {
|
||||
return getResultFile(new File(getLocalWorkspace(), Constants.err_file));
|
||||
}
|
||||
}
|
||||
9
src/_VisualDVM/TestingSystem/DVM/DVMTestingChecker.java
Normal file
9
src/_VisualDVM/TestingSystem/DVM/DVMTestingChecker.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package _VisualDVM.TestingSystem.DVM;
|
||||
import _VisualDVM.Repository.RepositoryClient;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
public class DVMTestingChecker extends RepositoryClient {
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
ServerCommand(ServerCode.StartNecessaryMachines);
|
||||
}
|
||||
}
|
||||
154
src/_VisualDVM/TestingSystem/DVM/DVMTestingPlanner.java
Normal file
154
src/_VisualDVM/TestingSystem/DVM/DVMTestingPlanner.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package _VisualDVM.TestingSystem.DVM;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.TestingSystem.Common.TasksPackageState;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPlanner;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMTask;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public abstract class DVMTestingPlanner extends TestingPlanner<DVMPackage> {
|
||||
public DVMTestingPlanner(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
LinkedHashMap<Integer, File> getTestsFromJson() {
|
||||
LinkedHashMap<Integer, File> res = new LinkedHashMap<>();
|
||||
for (DVMCompilationTask task : testingPackage.package_json.compilationTasks) {
|
||||
if (!res.containsKey(task.test_id)) {
|
||||
res.put(task.test_id, Paths.get(Global.TestsDirectory.getAbsolutePath(), String.valueOf(task.test_id)).toFile());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
static LinkedHashMap<LanguageName, Vector<ProjectFile>> getTestPrograms(File test) {
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>();
|
||||
//--
|
||||
res.put(LanguageName.fortran, new Vector<>());
|
||||
res.put(LanguageName.c, new Vector<>());
|
||||
res.put(LanguageName.cpp, new Vector<>());
|
||||
//--
|
||||
File[] files = test.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.isFile();
|
||||
}
|
||||
});
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
ProjectFile projectFile = new ProjectFile(new File(file.getName()));
|
||||
if (projectFile.isNotExcludedProgram()) res.get(projectFile.languageName).add(projectFile);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
static void generateForLanguage(String dvm_drv, LanguageName language, Vector<ProjectFile> language_programs, Vector<String> titles, Vector<String> objects, Vector<String> bodies, String flags) {
|
||||
if (!language_programs.isEmpty()) {
|
||||
String LANG_ = language.toString().toUpperCase() + "_";
|
||||
Vector<String> module_objects = new Vector<>();
|
||||
String module_body = "";
|
||||
int i = 1;
|
||||
for (ProjectFile program : language_programs) {
|
||||
//--
|
||||
String object = CommonUtils.DQuotes(language + "_" + i + ".o");
|
||||
module_objects.add(object);
|
||||
module_body += object + ":\n" + "\t" + String.join(" ", Utils.MFVar(LANG_ + "COMMAND"), Utils.MFVar(LANG_ + "FLAGS"), program.getStyleOptions(), "-c", program.getQSourceName(), "-o", object + "\n\n");
|
||||
++i;
|
||||
}
|
||||
titles.add(String.join("\n", LANG_ + "COMMAND=" + CommonUtils.DQuotes(dvm_drv) + " " + language.getDVMCompile(), LANG_ + "FLAGS=" + flags, LANG_ + "OBJECTS=" + String.join(" ", module_objects), ""));
|
||||
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
|
||||
bodies.add(module_body);
|
||||
}
|
||||
}
|
||||
static String generateMakefile(File test, LanguageName test_language, String dvm_drv, String flags) {
|
||||
//----->>
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> programs = getTestPrograms(test);
|
||||
Vector<String> titles = new Vector<>();
|
||||
Vector<String> objects = new Vector<>();
|
||||
Vector<String> bodies = new Vector<>();
|
||||
String binary = CommonUtils.DQuotes("0");
|
||||
//----->>
|
||||
for (LanguageName languageName : programs.keySet()) {
|
||||
generateForLanguage(dvm_drv, languageName, programs.get(languageName), titles, objects, bodies, flags);
|
||||
}
|
||||
//----->>
|
||||
return String.join("\n", "LINK_COMMAND=" + CommonUtils.DQuotes(dvm_drv) + " " + test_language.getDVMLink(), "LINK_FLAGS=" + flags + "\n", String.join("\n", titles), "all: " + binary, binary + " : " + String.join(" ", objects), "\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary, String.join(" ", bodies));
|
||||
}
|
||||
public void getTasksInfo(List<? extends DVMTask> tasks, String file_name) throws Exception {
|
||||
LinkedHashMap<Integer, DVMTask> sorted_tasks = new LinkedHashMap<>();
|
||||
for (DVMTask task : tasks)
|
||||
sorted_tasks.put(task.id, task);
|
||||
//--
|
||||
File info_file = Paths.get(packageLocalWorkspace.getAbsolutePath(), "results", file_name).toFile();
|
||||
List<String> lines = FileUtils.readLines(info_file, Charset.defaultCharset());
|
||||
for (String packed : lines) {
|
||||
if (!packed.isEmpty()) {
|
||||
String[] data = packed.split(" ");
|
||||
int id = Integer.parseInt(data[0]);
|
||||
TaskState state = TaskState.valueOf(data[1]);
|
||||
double time = Double.parseDouble(data[2]);
|
||||
//--
|
||||
DVMTask task = sorted_tasks.get(id);
|
||||
task.state = state;
|
||||
task.Time = state.equals(TaskState.AbortedByTimeout) ? (task.maxtime + 1) : time;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void Print(String message) {
|
||||
try {
|
||||
if (isPrintOn()) {
|
||||
System.out.println(message);
|
||||
CommonUtils.MainLog.Print(message);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected ServerCode getActivePackagesCode() {
|
||||
return ServerCode.GetFirstActiveDVMPackageForMachineURL;
|
||||
}
|
||||
@Override
|
||||
protected ServerCode getCheckIfNeedsKillCode() {
|
||||
return ServerCode.DVMPackageNeedsKill;
|
||||
}
|
||||
@Override
|
||||
protected TasksPackageState getStateAfterStart() {
|
||||
return TasksPackageState.CompilationWorkspacesCreation;
|
||||
}
|
||||
@Override
|
||||
protected void ServerConnectionError(ServerCode code_in, String logText) throws Exception {
|
||||
Finalize("Не удалось выполнить команду " + code_in + " на сервере тестирования\n" + logText);
|
||||
}
|
||||
protected abstract boolean CheckModules() throws Exception;
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
Print("Проверка сервера...");
|
||||
String currentServerName = (String) ServerCommand(ServerCode.GetServerName);
|
||||
Print("имя текущего сервера " + CommonUtils.Brackets(currentServerName));
|
||||
Print("имя сервера, создавшего нить " + CommonUtils.Brackets(serverName));
|
||||
if (!serverName.equals(currentServerName)) {
|
||||
Finalize("Несоответствующий сервер");
|
||||
}
|
||||
Print("Запрос активных пакетов для машины " + CommonUtils.Brackets(machine.getURL()));
|
||||
testingPackage = null;
|
||||
Vector<DVMPackage> activePackages = (Vector<DVMPackage>) ServerCommand(getActivePackagesCode(), machine.getURL(), null);
|
||||
if (activePackages.isEmpty())
|
||||
Finalize("Не найдено активных пакетов для машины " + CommonUtils.Brackets(machine.getURL()));
|
||||
for (DVMPackage activePackage : activePackages)
|
||||
PerformPackage(activePackage);
|
||||
}
|
||||
}
|
||||
85
src/_VisualDVM/TestingSystem/DVM/LocalDVMTestingPlanner.java
Normal file
85
src/_VisualDVM/TestingSystem/DVM/LocalDVMTestingPlanner.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package _VisualDVM.TestingSystem.DVM;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedHashMap;
|
||||
public class LocalDVMTestingPlanner extends DVMTestingPlanner {
|
||||
public LocalDVMTestingPlanner(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
@Override
|
||||
protected boolean CheckModules() throws Exception {
|
||||
/*
|
||||
File modulesDirectory = Paths.get(user.workspace, "modules").toFile();
|
||||
File version = new File(modulesDirectory,"version.h");
|
||||
int current_version = Constants.Nan;
|
||||
int actual_version = Constants.planner_version;
|
||||
///--
|
||||
if (version.exists()) {
|
||||
try {
|
||||
current_version = Integer.parseInt(FileUtils.readFileToString(version));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
if (current_version < actual_version) {
|
||||
Print("Закачка кода модулей...");
|
||||
for (String resource_name : Constants.resourses_names) {
|
||||
Print(resource_name);
|
||||
File src = Utils.CreateTempResourceFile(resource_name);
|
||||
File dst = new File(modulesDirectory, resource_name);
|
||||
FileUtils.copyFile(src, dst);
|
||||
}
|
||||
//--
|
||||
Print("Сборка модулей...");
|
||||
String modules_log = user.connection.compileModules(modulesDirectory);
|
||||
if (!modules_log.isEmpty()) {
|
||||
testingPackage.description = modules_log;
|
||||
testingPackage.state = TasksPackageState.Aborted;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String packageDescription() {
|
||||
return "DVM";
|
||||
}
|
||||
@Override
|
||||
protected void TestsSynchronize() throws Exception {
|
||||
testingPackage.readJson();
|
||||
LinkedHashMap<Integer, File> tests = getTestsFromJson();
|
||||
//синхронизировать их.
|
||||
for (int test_id : tests.keySet()) {
|
||||
File test = tests.get(test_id);
|
||||
File testDst = Paths.get(testingPackage.user_workspace,"projects", String.valueOf(test_id)).toFile();
|
||||
Print(testDst.getAbsolutePath());
|
||||
FileUtils.copyDirectory(test,testDst);
|
||||
}
|
||||
Finalize("+");
|
||||
}
|
||||
@Override
|
||||
protected void PackageWorkspaceCreation() throws Exception {
|
||||
}
|
||||
@Override
|
||||
protected void AnalyseResults() throws Exception {
|
||||
}
|
||||
@Override
|
||||
protected void PackageStart() throws Exception {
|
||||
}
|
||||
@Override
|
||||
protected boolean CheckNextState() throws Exception {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void DownloadResults() throws Exception {
|
||||
}
|
||||
@Override
|
||||
protected void Kill() throws Exception {
|
||||
}
|
||||
|
||||
}
|
||||
277
src/_VisualDVM/TestingSystem/DVM/RemoteDVMTestingPlanner.java
Normal file
277
src/_VisualDVM/TestingSystem/DVM/RemoteDVMTestingPlanner.java
Normal file
@@ -0,0 +1,277 @@
|
||||
package _VisualDVM.TestingSystem.DVM;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.TestingSystem.Common.TasksPackageState;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMRunTask;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
public class RemoteDVMTestingPlanner extends DVMTestingPlanner {
|
||||
RemoteFile packageRemoteWorkspace = null;
|
||||
public RemoteDVMTestingPlanner(String... args) {
|
||||
super(args);
|
||||
}
|
||||
@Override
|
||||
protected boolean Connect() {
|
||||
if (user.connection == null) {
|
||||
try {
|
||||
user.connection = new UserConnection(machine, user);
|
||||
Print("Соединение c " + machine.getURL() + " " + user.login + " успешно установлено.");
|
||||
Print("Проверка инициализации..");
|
||||
user.connection.CheckUserInitialization(testingPackage.sender_address);
|
||||
} catch (Exception ex) {
|
||||
Print(ex.toString());
|
||||
user.connection = null;
|
||||
Print("Не удалось установить соединение.");
|
||||
}
|
||||
}
|
||||
return user.connection != null;
|
||||
}
|
||||
@Override
|
||||
protected void Disconnect() {
|
||||
if (user.connection != null) {
|
||||
user.connection.Disconnect();
|
||||
user.connection = null;
|
||||
Print("Соединение c " + machine.getURL() + " " + user.login + " сброшено.");
|
||||
}
|
||||
}
|
||||
//----
|
||||
@Override
|
||||
protected void TestsSynchronize() throws Exception {
|
||||
System.out.println("--");
|
||||
testingPackage.readJson();
|
||||
System.out.println("+");
|
||||
LinkedHashMap<Integer, File> tests = getTestsFromJson();
|
||||
//синхронизировать их.
|
||||
for (int test_id : tests.keySet()) {
|
||||
System.out.println("test=" + test_id);
|
||||
File test = tests.get(test_id);
|
||||
RemoteFile test_dst = new RemoteFile(testingPackage.user_workspace + "/projects/" + test_id, true);
|
||||
user.connection.MKDIR(test_dst);
|
||||
user.connection.SynchronizeSubDirsR(test, test_dst);
|
||||
}
|
||||
System.out.println("++");
|
||||
}
|
||||
@Override
|
||||
protected void PackageWorkspaceCreation() throws Exception {
|
||||
System.out.println("package workspace creation");
|
||||
if (!CheckModules()) {
|
||||
return;
|
||||
}
|
||||
System.out.println("modules checked");
|
||||
//--
|
||||
testingPackage.readJson();
|
||||
//--
|
||||
LinkedHashMap<Integer, File> tests = getTestsFromJson();
|
||||
//создать папку для пакета.
|
||||
user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
||||
user.connection.sftpChannel.mkdir(packageRemoteWorkspace.full_name);
|
||||
//положить туда запакованные тексты задач.
|
||||
Vector<String> compilationLines = new Vector<>();
|
||||
Vector<String> runLines = new Vector<>();
|
||||
for (DVMCompilationTask compilationTask : testingPackage.package_json.compilationTasks) {
|
||||
String makefileText = generateMakefile(tests.get(compilationTask.test_id), compilationTask.language, testingPackage.drv, compilationTask.flags);
|
||||
compilationLines.addAll(compilationTask.pack(makefileText));
|
||||
for (DVMRunTask runTask : compilationTask.runTasks)
|
||||
runLines.addAll(runTask.pack(null));
|
||||
}
|
||||
RemoteFile compilationPackage = new RemoteFile(packageRemoteWorkspace, "compilationTasks");
|
||||
RemoteFile runPackage = new RemoteFile(packageRemoteWorkspace, "runTasks");
|
||||
user.connection.writeToFile(String.join("\n", compilationLines) + "\n", compilationPackage);
|
||||
user.connection.writeToFile(String.join("\n", runLines) + "\n", runPackage);
|
||||
// --
|
||||
user.connection.MKDIR(new RemoteFile(packageRemoteWorkspace, "state"));
|
||||
}
|
||||
@Override
|
||||
protected void AnalyseResults() throws Exception {
|
||||
boolean hasErrors = false;
|
||||
testingPackage.readJson();
|
||||
Print("analysing results");
|
||||
Vector<DVMRunTask> runTasks = new Vector<>();
|
||||
for (DVMCompilationTask compilationTask : testingPackage.package_json.compilationTasks)
|
||||
runTasks.addAll(compilationTask.runTasks);
|
||||
//----
|
||||
getTasksInfo(testingPackage.package_json.compilationTasks, "CompilationInfo.txt");
|
||||
getTasksInfo(runTasks, "RunningInfo.txt");
|
||||
//--
|
||||
int ct_count = 0;
|
||||
int rt_count = 0;
|
||||
int good=0;
|
||||
//--
|
||||
for (DVMCompilationTask compilationTask : testingPackage.package_json.compilationTasks) {
|
||||
compilationTask.dvm_package_id = testingPackage.id;
|
||||
if (!compilationTask.state.equals(TaskState.Done))
|
||||
hasErrors = true;
|
||||
ct_count++;
|
||||
File ct_workspace = Paths.get(packageLocalWorkspace.getAbsolutePath(), "results", String.valueOf(compilationTask.id)).toFile();
|
||||
if (ct_workspace.exists()) {
|
||||
for (DVMRunTask runTask : compilationTask.runTasks) {
|
||||
runTask.dvm_package_id = testingPackage.id;
|
||||
rt_count++;
|
||||
runTask.compilation_state = compilationTask.state;
|
||||
runTask.compilation_time = compilationTask.Time;
|
||||
if (compilationTask.state == TaskState.DoneWithErrors) {
|
||||
runTask.state = TaskState.Canceled;
|
||||
} else {
|
||||
File rt_workspace = Paths.get(packageLocalWorkspace.getAbsolutePath(), "results", String.valueOf(runTask.id)).toFile();
|
||||
if (rt_workspace.exists() && runTask.state.equals(TaskState.Finished)) {
|
||||
//анализ задачи на запуск.
|
||||
File outFile = new File(rt_workspace, Constants.out_file);
|
||||
File errFile = new File(rt_workspace.getAbsolutePath(), Constants.err_file);
|
||||
//--
|
||||
String output = FileUtils.readFileToString(outFile);
|
||||
String errors = FileUtils.readFileToString(errFile);
|
||||
//--
|
||||
List<String> output_lines = Arrays.asList(output.split("\n"));
|
||||
List<String> errors_lines = Arrays.asList(errors.split("\n"));
|
||||
//---
|
||||
if (Utils.isCrushed(output_lines, errors_lines)) {
|
||||
runTask.state = TaskState.Crushed;
|
||||
} else {
|
||||
Pair<TaskState, Integer> results = new Pair<>(TaskState.Done, 100);
|
||||
switch (runTask.test_type) {
|
||||
case Correctness:
|
||||
results = Utils.analyzeCorrectness(output_lines);
|
||||
break;
|
||||
case Performance:
|
||||
results = Utils.analyzePerformance(output_lines);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
runTask.state = results.getKey();
|
||||
runTask.progress = results.getValue();
|
||||
runTask.CleanTime = Utils.parseCleanTime(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!runTask.state.equals(TaskState.Done))
|
||||
hasErrors = true;
|
||||
else good++;
|
||||
}
|
||||
}
|
||||
}
|
||||
testingPackage.progress = 100;
|
||||
testingPackage.saveJson(); //запись обновленных результатов пакета в json!
|
||||
Print("analysis done, ct_count=" + ct_count + " rt count=" + rt_count);
|
||||
testingPackage.state = hasErrors ? TasksPackageState.DoneWithErrors : TasksPackageState.Done;
|
||||
double percent = ( ((double)(good))/testingPackage.tasksCount)*100.0;
|
||||
testingPackage.description = "Выполнено на "+((int)percent)+"%\n"+
|
||||
"Всего задач: "+testingPackage.tasksCount+", из них с ошибками "+(testingPackage.tasksCount-good);
|
||||
UpdatePackageState();
|
||||
}
|
||||
@Override
|
||||
protected void PackageStart() throws Exception {
|
||||
String plannerStartCommand = String.join(" ",
|
||||
CommonUtils.DQuotes(getPlanner()),
|
||||
CommonUtils.DQuotes(user.workspace),
|
||||
CommonUtils.DQuotes(packageRemoteWorkspace.full_name),
|
||||
CommonUtils.DQuotes(testingPackage.kernels),
|
||||
CommonUtils.DQuotes(testingPackage.drv));
|
||||
user.connection.startShellProcess(packageRemoteWorkspace, "planner_output",
|
||||
"ulimit -s unlimited", plannerStartCommand);
|
||||
//---
|
||||
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
|
||||
while (!user.connection.Exists(PID)) {
|
||||
Print("PID not found");
|
||||
CommonUtils.sleep(1000);
|
||||
}
|
||||
testingPackage.PID = user.connection.readFromFile(PID).replace("\n", "").replace("\r", "");
|
||||
//---
|
||||
System.out.println("PID=" + CommonUtils.Brackets(testingPackage.PID));
|
||||
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");
|
||||
while (!user.connection.Exists(STARTED)) {
|
||||
Print("waiting for package start...");
|
||||
CommonUtils.sleep(1000);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean CheckNextState() throws Exception {
|
||||
boolean progress_changed = false;
|
||||
boolean state_changed = false;
|
||||
RemoteFile progress = new RemoteFile(packageRemoteWorkspace, "progress");
|
||||
if (user.connection.Exists(progress)) {
|
||||
String s = user.connection.readFromFile(progress);
|
||||
int current_progress = Integer.parseInt(s);
|
||||
if (current_progress != testingPackage.progress) {
|
||||
Print("progress changed: " + current_progress);
|
||||
testingPackage.progress = current_progress;
|
||||
progress_changed = true;
|
||||
}
|
||||
}
|
||||
RemoteFile stateDir = new RemoteFile(packageRemoteWorkspace, "state");
|
||||
//состояния пакета могут меняться только по возрастанию. ищем, появилось ли такое.
|
||||
Vector<TasksPackageState> higherStates = testingPackage.state.getHigherStates();
|
||||
Collections.reverse(higherStates); //берем в обратном порядке, чтобы быстрее найти высшее.
|
||||
for (TasksPackageState state : higherStates) {
|
||||
RemoteFile file = new RemoteFile(stateDir, state.toString());
|
||||
if (user.connection.Exists(file)) {
|
||||
Print("found new state: " + file.name);
|
||||
testingPackage.state = state;
|
||||
state_changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//--
|
||||
user.connection.iterations++;
|
||||
if (user.connection.iterations == 100) {
|
||||
Disconnect();
|
||||
}
|
||||
//--
|
||||
return progress_changed || state_changed;
|
||||
}
|
||||
@Override
|
||||
protected void DownloadResults() throws Exception {
|
||||
Utils.CheckDirectory(packageLocalWorkspace);
|
||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace, "results.zip");
|
||||
File results_archive = new File(packageLocalWorkspace, "results.zip");
|
||||
user.connection.performScript(packageRemoteWorkspace, "zip -r " + CommonUtils.DQuotes("results.zip") + " " + CommonUtils.DQuotes("results"));
|
||||
//---
|
||||
if (user.connection.Exists(remote_results_archive)) {
|
||||
user.connection.getSingleFile(remote_results_archive.full_name, results_archive.getAbsolutePath());
|
||||
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
||||
unzipFolderPass.Do(results_archive.getAbsolutePath(), packageLocalWorkspace.getAbsolutePath(), false);
|
||||
}
|
||||
//---
|
||||
if (Global.properties.eraseTestingWorkspaces && user.connection.Exists(packageRemoteWorkspace))
|
||||
user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
||||
}
|
||||
@Override
|
||||
protected void MachineConnectionError() {
|
||||
Finalize("Количество безуспешных попыток соединения с машиной " + machine.getURL() + " превысило 10");
|
||||
}
|
||||
@Override
|
||||
protected void Kill() throws Exception {
|
||||
if (!testingPackage.PID.isEmpty()) {
|
||||
user.connection.Command("kill -9 " + testingPackage.PID);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void InitSessionCredentials() {
|
||||
packageRemoteWorkspace = new RemoteFile(user.workspace + "/tests", String.valueOf(testingPackage.id), true);
|
||||
packageLocalWorkspace = new File(Global.DVMPackagesDirectory, String.valueOf(testingPackage.id));
|
||||
}
|
||||
@Override
|
||||
protected boolean CheckModules() throws Exception {
|
||||
String log = user.connection.CheckModulesVersion();
|
||||
if (!log.isEmpty()) {
|
||||
testingPackage.description = log;
|
||||
testingPackage.state = TasksPackageState.Aborted;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String packageDescription() {
|
||||
return "DVM";
|
||||
}
|
||||
}
|
||||
570
src/_VisualDVM/TestingSystem/DVM/UserConnection.java
Normal file
570
src/_VisualDVM/TestingSystem/DVM/UserConnection.java
Normal file
@@ -0,0 +1,570 @@
|
||||
package _VisualDVM.TestingSystem.DVM;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.ProjectData.Project.db_project_info;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import com.jcraft.jsch.*;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class UserConnection {
|
||||
//http://www.jcraft.com/jsch/
|
||||
public int iterations = 0; //для тестирования
|
||||
//--
|
||||
public ChannelSftp sftpChannel = null;
|
||||
public ChannelShell shellChannel = null;
|
||||
public ChannelExec execChannel = null;
|
||||
//--
|
||||
JSch jsch = null;
|
||||
Session session = null;
|
||||
//---
|
||||
PipedInputStream in = null;
|
||||
PipedOutputStream out = null;
|
||||
//---
|
||||
PipedOutputStream pin = null;
|
||||
PipedInputStream pout = null;
|
||||
InputStreamReader fromServer = null;
|
||||
//---
|
||||
Machine machine = null;
|
||||
User user = null;
|
||||
//---
|
||||
public UserConnection(Machine machine_in, User user_in) throws Exception {
|
||||
machine = machine_in;
|
||||
user = user_in;
|
||||
//--
|
||||
session = (jsch = new JSch()).getSession(user.login, machine.address, machine.port);
|
||||
session.setPassword(user.password);
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
session.connect(0);
|
||||
//-->
|
||||
//создать канал для файлов
|
||||
sftpChannel = (ChannelSftp) session.openChannel("sftp");
|
||||
sftpChannel.connect();
|
||||
//-->
|
||||
//создать канал для команд
|
||||
}
|
||||
public void Disconnect() {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (pin != null) {
|
||||
try {
|
||||
pin.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (pout != null) {
|
||||
try {
|
||||
pout.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (fromServer != null) {
|
||||
try {
|
||||
fromServer.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (sftpChannel != null) sftpChannel.disconnect();
|
||||
if (shellChannel != null) shellChannel.disconnect();
|
||||
if (execChannel != null) execChannel.disconnect();
|
||||
if (session != null) {
|
||||
session.disconnect();
|
||||
}
|
||||
//----------------------
|
||||
sftpChannel = null;
|
||||
shellChannel = null;
|
||||
execChannel = null;
|
||||
session = null;
|
||||
//---
|
||||
in = null;
|
||||
out = null;
|
||||
//---
|
||||
pin = null;
|
||||
pout = null;
|
||||
fromServer = null;
|
||||
jsch = null;
|
||||
System.gc();
|
||||
}
|
||||
public void getSingleFile(String src, String dst) throws Exception {
|
||||
sftpChannel.get(src, dst);
|
||||
}
|
||||
public long getFileKBSize(String path) throws Exception {
|
||||
long size = sftpChannel.lstat(path).getSize();
|
||||
return size / 1024;
|
||||
}
|
||||
public void getSingleFileWithMaxSize(RemoteFile src, File dst, int maxSize) throws Exception {
|
||||
if ((maxSize == 0) || getFileKBSize(src.full_name) <= maxSize) {
|
||||
getSingleFile(src.full_name, dst.getAbsolutePath());
|
||||
} else {
|
||||
Utils.WriteToFile(dst, "Размер файла превышает " + maxSize + " KB.\n" + "Файл не загружен. Его можно просмотреть на машине по адресу\n" + CommonUtils.Brackets(src.full_name));
|
||||
}
|
||||
}
|
||||
public void putSingleFile(File src, RemoteFile dst) throws Exception {
|
||||
sftpChannel.put(src.getAbsolutePath(), dst.full_name);
|
||||
}
|
||||
//-
|
||||
public void MKDIR(RemoteFile dir) throws Exception {
|
||||
if (!Exists(dir)) sftpChannel.mkdir(dir.full_name);
|
||||
}
|
||||
//-
|
||||
public void RMDIR(String dir) throws Exception {
|
||||
if (!dir.isEmpty() && !dir.equals("/") && !dir.equals("\\") && !dir.equals("*")) {
|
||||
Command("rm -rf " + CommonUtils.DQuotes(dir));
|
||||
} else throw new PassException("Недопустимый путь для удаления папки " + CommonUtils.DQuotes(dir));
|
||||
}
|
||||
//-
|
||||
public void SynchronizeSubDirsR(File local_dir, RemoteFile remote_dir) throws Exception {
|
||||
File[] local_subdirs = local_dir.listFiles(File::isDirectory);
|
||||
File[] local_files = local_dir.listFiles(File::isFile);
|
||||
//------------------------------------------------------------------------
|
||||
LinkedHashMap<String, RemoteFile> remote_subdirs = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, RemoteFile> remote_files = new LinkedHashMap<>();
|
||||
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(remote_dir.full_name);
|
||||
for (ChannelSftp.LsEntry file : files) {
|
||||
if (file.getAttrs().isDir()) {
|
||||
if (!file.getFilename().equals(".") && !file.getFilename().equals(".."))
|
||||
remote_subdirs.put(file.getFilename(), new RemoteFile(remote_dir.full_name, file.getFilename(), true));
|
||||
} else {
|
||||
RemoteFile rf = new RemoteFile(remote_dir.full_name, file.getFilename());
|
||||
rf.updateTime = RemoteFile.convertUpdateTime(file.getAttrs().getMTime());
|
||||
remote_files.put(file.getFilename(), rf);
|
||||
}
|
||||
}
|
||||
if (local_subdirs != null) {
|
||||
for (File lsd : local_subdirs) {
|
||||
if (!lsd.getName().equals(Constants.data)) {
|
||||
RemoteFile rsd = null;
|
||||
if (!remote_subdirs.containsKey(lsd.getName()))
|
||||
sftpChannel.mkdir((rsd = new RemoteFile(remote_dir.full_name, lsd.getName(), true)).full_name);
|
||||
else rsd = remote_subdirs.get(lsd.getName());
|
||||
SynchronizeSubDirsR(lsd, rsd);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (local_files != null) {
|
||||
for (File lf : local_files) {
|
||||
RemoteFile rf = null;
|
||||
if (!remote_files.containsKey(lf.getName())) {
|
||||
rf = new RemoteFile(remote_dir.full_name, lf.getName());
|
||||
putSingleFile(lf, rf);
|
||||
} else {
|
||||
rf = remote_files.get(lf.getName());
|
||||
if (lf.lastModified() > rf.updateTime) {
|
||||
putSingleFile(lf, rf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void writeToFile(String text, RemoteFile dst) throws Exception {
|
||||
sftpChannel.put(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), dst.full_name);
|
||||
sftpChannel.chmod(0777, dst.full_name);
|
||||
}
|
||||
public String readFromFile(RemoteFile src) throws Exception {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
sftpChannel.get(src.full_name, outputStream);
|
||||
return outputStream.toString(StandardCharsets.UTF_8.name());
|
||||
}
|
||||
//--
|
||||
public boolean Exists(String file_full_name) throws Exception {
|
||||
try {
|
||||
sftpChannel.lstat(file_full_name);
|
||||
return true;
|
||||
|
||||
} catch (SftpException e) {
|
||||
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
|
||||
// file doesn't exist
|
||||
return false;
|
||||
} else {
|
||||
// something else went wrong
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean Busy(String file_full_name) throws Exception {
|
||||
try {
|
||||
sftpChannel.lstat(file_full_name);
|
||||
return true;
|
||||
|
||||
} catch (SftpException e) {
|
||||
if (e.id == ChannelSftp.SSH_FX_PERMISSION_DENIED) {
|
||||
// file busy
|
||||
return false;
|
||||
} else {
|
||||
// something else went wrong
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean Busy(RemoteFile file) throws Exception {
|
||||
return Busy(file.full_name);
|
||||
}
|
||||
public boolean Exists(RemoteFile file) throws Exception {
|
||||
return Exists(file.full_name);
|
||||
}
|
||||
//--
|
||||
public Pair<RemoteFile, RemoteFile> performScript(RemoteFile directory, String... commands) throws Exception {
|
||||
RemoteFile script_file = new RemoteFile(directory, Constants.script);
|
||||
RemoteFile out = new RemoteFile(directory, Constants.out_file);
|
||||
RemoteFile err = new RemoteFile(directory, Constants.err_file);
|
||||
//
|
||||
Vector<RemoteFile> files = new Vector<>();
|
||||
files.add(script_file);
|
||||
files.add(out);
|
||||
files.add(err);
|
||||
for (RemoteFile file : files) {
|
||||
if (Exists(file))
|
||||
sftpChannel.rm(file.full_name);
|
||||
}
|
||||
//--
|
||||
writeToFile("cd " + CommonUtils.DQuotes(directory.full_name) + "\n" + String.join("\n", commands), script_file);
|
||||
//--
|
||||
Command(CommonUtils.DQuotes(script_file.full_name) + " 1>" + CommonUtils.DQuotes(out.full_name) + " 2>" + CommonUtils.DQuotes(err.full_name));
|
||||
return new Pair<>(out, err);
|
||||
}
|
||||
public void putResource(RemoteFile dstDirectory, String resource_name) throws Exception {
|
||||
File src = Utils.CreateTempResourceFile(resource_name);
|
||||
RemoteFile dst = new RemoteFile(dstDirectory, resource_name);
|
||||
putSingleFile(src, dst);
|
||||
}
|
||||
boolean compileModule(RemoteFile modulesDirectory, String module_name) throws Exception {
|
||||
String flags = module_name.equals("planner") ? getAvailibleCPPStandard(modulesDirectory) : "";
|
||||
String command = "g++ -O3 " + flags + " " + CommonUtils.DQuotes(module_name + ".cpp") + " -o " + CommonUtils.DQuotes(module_name);
|
||||
RemoteFile binary = new RemoteFile(modulesDirectory, module_name);
|
||||
//--
|
||||
if (Exists(binary))
|
||||
sftpChannel.rm(binary.full_name);
|
||||
//--
|
||||
performScript(modulesDirectory, command);
|
||||
//--
|
||||
if (Exists(binary)) {
|
||||
sftpChannel.chmod(0777, binary.full_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
String getAvailibleCPPStandard(RemoteFile scriptDirectory) throws Exception {
|
||||
String res = "";
|
||||
String command = "g++ -v --help 2> /dev/null | sed -n '/^ *-std=\\([^<][^ ]\\+\\).*/ {s//\\1/p}' | grep c++";
|
||||
Pair<RemoteFile, RemoteFile> oe = performScript(scriptDirectory, command);
|
||||
RemoteFile outFile = oe.getKey();
|
||||
String out = readFromFile(outFile);
|
||||
//--
|
||||
RemoteFile cppVersionsInfo = new RemoteFile(scriptDirectory, "cpp_versions.txt");
|
||||
sftpChannel.rename(outFile.full_name, cppVersionsInfo.full_name);
|
||||
//--
|
||||
String[] data = out.split("\n");
|
||||
boolean cpp_17 = false;
|
||||
boolean cpp_11 = false;
|
||||
//определить какие есть версии.
|
||||
for (String version : data) {
|
||||
switch (version) {
|
||||
case "c++17":
|
||||
cpp_17 = true;
|
||||
break;
|
||||
case "c++11":
|
||||
cpp_11 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cpp_17)
|
||||
res = "-std=c++17";
|
||||
else if (cpp_11)
|
||||
res = "-std=c++11";
|
||||
RemoteFile cppFlag = new RemoteFile(scriptDirectory, "current_ccp_version");
|
||||
writeToFile(res, cppFlag);
|
||||
return res;
|
||||
}
|
||||
public String compileModules(RemoteFile modulesDirectory) throws Exception {
|
||||
if (!compileModule(modulesDirectory, "launcher")) {
|
||||
return "Не удалось собрать модуль [launcher]";
|
||||
}
|
||||
if (!compileModule(modulesDirectory, "starter")) {
|
||||
return "Не удалось собрать модуль [starter]";
|
||||
}
|
||||
if (!compileModule(modulesDirectory, "planner")) {
|
||||
return "Не удалось собрать модуль [planner]";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
//--
|
||||
public void tryRM(RemoteFile file) throws Exception {
|
||||
if (Exists(file))
|
||||
sftpChannel.rm(file.full_name);
|
||||
}
|
||||
//с проверкой.
|
||||
public boolean tryGetSingleFileWithMaxSize(RemoteFile src, File dst, int maxSize) throws Exception {
|
||||
if (Exists(src)) {
|
||||
if ((maxSize == 0) || (getFileKBSize(src.full_name) <= maxSize)) {
|
||||
getSingleFile(src.full_name, dst.getAbsolutePath());
|
||||
return true;
|
||||
} else {
|
||||
Utils.WriteToFile(dst, "Размер файла превышает " + maxSize + " KB.\n" + "Файл не загружен. Его можно просмотреть на машине по адресу\n" + CommonUtils.Brackets(src.full_name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
public void SynchronizeProjectSubDirsR(db_project_info project, File local_dir, RemoteFile remote_dir, boolean data) throws Exception {
|
||||
// ShowMessage2("синхронизация: " + local_dir.getName());
|
||||
Vector<File> local_subdirs = project.getSubdirectoriesSimple(local_dir);
|
||||
Vector<File> local_files = project.getActiveFilesForSynchronization(local_dir, data);
|
||||
//------------------------------------------------------------------------
|
||||
LinkedHashMap<String, RemoteFile> remote_subdirs = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, RemoteFile> remote_files = new LinkedHashMap<>();
|
||||
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(remote_dir.full_name);
|
||||
for (ChannelSftp.LsEntry file : files) {
|
||||
if (file.getAttrs().isDir()) {
|
||||
if (!file.getFilename().equals(".") && !file.getFilename().equals(".."))
|
||||
remote_subdirs.put(file.getFilename(), new RemoteFile(remote_dir.full_name, file.getFilename(), true));
|
||||
} else {
|
||||
RemoteFile rf = new RemoteFile(remote_dir.full_name, file.getFilename());
|
||||
rf.updateTime = RemoteFile.convertUpdateTime(file.getAttrs().getMTime());
|
||||
remote_files.put(file.getFilename(), rf);
|
||||
}
|
||||
}
|
||||
for (File lsd : local_subdirs) {
|
||||
RemoteFile rsd = null;
|
||||
if (!remote_subdirs.containsKey(lsd.getName()))
|
||||
sftpChannel.mkdir((rsd = new RemoteFile(remote_dir.full_name, lsd.getName(), true)).full_name);
|
||||
else rsd = remote_subdirs.get(lsd.getName());
|
||||
SynchronizeProjectSubDirsR(project, lsd, rsd, data);
|
||||
}
|
||||
for (File lf : local_files) {
|
||||
RemoteFile rf = null;
|
||||
if (!remote_files.containsKey(lf.getName())) {
|
||||
rf = new RemoteFile(remote_dir.full_name, lf.getName());
|
||||
// ShowMessage2(lf.getName());
|
||||
putSingleFile(lf, rf);
|
||||
} else {
|
||||
rf = remote_files.get(lf.getName());
|
||||
if (lf.lastModified() > rf.updateTime) {
|
||||
// ShowMessage2(lf.getName());
|
||||
putSingleFile(lf, rf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//--
|
||||
public Vector<RemoteFile> getFilesByExtensions(RemoteFile dir, String... extensions) throws Exception {
|
||||
Vector<RemoteFile> res = new Vector<>();
|
||||
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(dir.full_name);
|
||||
for (ChannelSftp.LsEntry file : files) {
|
||||
String[] data = file.getFilename().split("\\.");
|
||||
if (data.length > 1) {
|
||||
String file_extension = data[data.length - 1];
|
||||
for (String extension : extensions) {
|
||||
if (file_extension.equalsIgnoreCase(extension))
|
||||
res.add(new RemoteFile(dir.full_name, file.getFilename()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public void deleteFilesByExtensions(RemoteFile dir, String... extensions) throws Exception {
|
||||
Vector<RemoteFile> to_delete = getFilesByExtensions(dir, extensions);
|
||||
for (RemoteFile file : to_delete)
|
||||
sftpChannel.rm(file.full_name);
|
||||
}
|
||||
public void Command(String... commands) throws Exception {
|
||||
if (commands.length > 0) {
|
||||
String command = String.join("\n", commands);
|
||||
execChannel = (ChannelExec) session.openChannel("exec");
|
||||
execChannel.setErrStream(System.err);
|
||||
execChannel.setCommand(command);
|
||||
execChannel.connect();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(execChannel.getInputStream()));
|
||||
String line = null;
|
||||
while ((line = in.readLine()) != null) {
|
||||
System.out.println(CommonUtils.Brackets(line));
|
||||
}
|
||||
}
|
||||
execChannel.disconnect();
|
||||
}
|
||||
public void CommandNoWait(String... commands) throws Exception {
|
||||
if (commands.length > 0) {
|
||||
String command = String.join("\n", commands);
|
||||
execChannel = (ChannelExec) session.openChannel("exec");
|
||||
execChannel.setErrStream(System.err);
|
||||
execChannel.setCommand(command);
|
||||
execChannel.connect();
|
||||
execChannel.disconnect();
|
||||
}
|
||||
}
|
||||
//-----
|
||||
public void ShellConnect() throws Exception {
|
||||
shellChannel = (ChannelShell) session.openChannel("shell");
|
||||
in = new PipedInputStream();
|
||||
out = new PipedOutputStream();
|
||||
//--
|
||||
shellChannel.setInputStream(in);
|
||||
shellChannel.setOutputStream(out);
|
||||
pin = new PipedOutputStream(in);
|
||||
pout = new PipedInputStream(out);
|
||||
shellChannel.connect();
|
||||
//-
|
||||
fromServer = new InputStreamReader(pout);
|
||||
/*
|
||||
ShellParser.setUserName(user.login);
|
||||
ShellParser.ReadInvitation(fromServer); //прочитать первое приглашение от машины.
|
||||
*/
|
||||
}
|
||||
public void ShellDisconnect() throws Exception {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (pin != null) {
|
||||
try {
|
||||
pin.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (pout != null) {
|
||||
try {
|
||||
pout.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (fromServer != null) {
|
||||
try {
|
||||
fromServer.close();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
}
|
||||
if (shellChannel != null) shellChannel.disconnect();
|
||||
//--
|
||||
in = null;
|
||||
out = null;
|
||||
pin = null;
|
||||
pout = null;
|
||||
fromServer = null;
|
||||
shellChannel = null;
|
||||
System.gc();
|
||||
}
|
||||
public void waitForFileCreation(RemoteFile file) throws Exception {
|
||||
while (!Exists(file)) {
|
||||
System.out.println(file.full_name + " NOT FOUND");
|
||||
CommonUtils.sleep(1000);
|
||||
}
|
||||
}
|
||||
public void waitForFileFree(RemoteFile file) throws Exception {
|
||||
while (!Busy(file)) {
|
||||
System.out.println(file.full_name + " PERMISSION DENIED");
|
||||
CommonUtils.sleep(1000);
|
||||
}
|
||||
}
|
||||
public String startShellProcess(RemoteFile directory, String outFileName, String... commands) throws Exception {
|
||||
Vector<String> commands_ = new Vector<>();
|
||||
commands_.add("cd " + CommonUtils.DQuotes(directory.full_name));
|
||||
for (int i = 0; i < commands.length; ++i) {
|
||||
if (i == commands.length - 1) {
|
||||
commands_.add(commands[i] + " 1>" + CommonUtils.DQuotes(outFileName));
|
||||
} else {
|
||||
commands_.add(commands[i]);
|
||||
}
|
||||
}
|
||||
RemoteFile script_file = new RemoteFile(directory, Constants.script);
|
||||
if (Exists(script_file))
|
||||
sftpChannel.rm(script_file.full_name);
|
||||
writeToFile(String.join("\n", commands_), script_file);
|
||||
String start_command = CommonUtils.DQuotes(script_file.full_name);
|
||||
//--
|
||||
RemoteFile outFile = new RemoteFile(directory, outFileName);
|
||||
if (Exists(outFile))
|
||||
sftpChannel.rm(outFile.full_name);
|
||||
ShellConnect();
|
||||
pin.write(("nohup " + start_command + " &\r\n").getBytes());
|
||||
waitForFileCreation(outFile);
|
||||
waitForFileFree(outFile);
|
||||
ShellDisconnect();
|
||||
return readFromFile(outFile).replace("\n", "").replace("\r", "");
|
||||
}
|
||||
//-- проверка существования рабочего пространства.
|
||||
public void CheckUserInitialization(String email) throws Exception {
|
||||
RemoteFile userWorkspace = new RemoteFile(user.workspace, true);
|
||||
if (!Exists(userWorkspace)) {
|
||||
sftpChannel.mkdir(userWorkspace.full_name);
|
||||
//--
|
||||
RemoteFile modulesDirectory = new RemoteFile(userWorkspace, "modules");
|
||||
RemoteFile projectsDirectory = new RemoteFile(userWorkspace, "projects");
|
||||
RemoteFile testsDirectory = new RemoteFile(userWorkspace, "tests");
|
||||
//--
|
||||
Vector<RemoteFile> subdirectories = new Vector<>();
|
||||
subdirectories.add(modulesDirectory);
|
||||
subdirectories.add(projectsDirectory);
|
||||
subdirectories.add(testsDirectory);
|
||||
for (RemoteFile remoteFile : subdirectories)
|
||||
sftpChannel.mkdir(remoteFile.full_name);
|
||||
//--
|
||||
for (String resource_name : Constants.resourses_names) {
|
||||
putResource(modulesDirectory, resource_name);
|
||||
}
|
||||
//-
|
||||
String modules_log = compileModules(modulesDirectory);
|
||||
if (!modules_log.isEmpty())
|
||||
throw new PassException(modules_log);
|
||||
//--
|
||||
RemoteFile info = new RemoteFile(userWorkspace, email);
|
||||
user.connection.writeToFile("", info);
|
||||
}
|
||||
}
|
||||
//--
|
||||
public String CheckModulesVersion() throws Exception {
|
||||
RemoteFile modulesDirectory = new RemoteFile(user.workspace, "modules");
|
||||
RemoteFile version = new RemoteFile(modulesDirectory, "version.h");
|
||||
int current_version = CommonConstants.Nan;
|
||||
int actual_version = Constants.planner_version;
|
||||
if (Exists(version)) {
|
||||
try {
|
||||
current_version = Integer.parseInt(readFromFile(version));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (current_version < actual_version) {
|
||||
for (String resource_name : Constants.resourses_names) {
|
||||
putResource(modulesDirectory, resource_name);
|
||||
}
|
||||
//--
|
||||
return compileModules(modulesDirectory);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user