Compare commits
3 Commits
79aa1678b2
...
eec6266e20
| Author | SHA1 | Date |
|---|---|---|
|
|
eec6266e20 | |
|
|
92cc447771 | |
|
|
0c50656f13 |
|
|
@ -0,0 +1 @@
|
||||||
|
*.log
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -35,19 +35,19 @@ dist.jlink.dir=${dist.dir}/jlink
|
||||||
dist.jlink.output=${dist.jlink.dir}/jNetLib
|
dist.jlink.output=${dist.jlink.dir}/jNetLib
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.apache-commons-configuration2-2.9.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-configuration2-2.9.0.jar
|
file.reference.apache-commons-configuration2-2.9.0.jar=lib\\apache-commons-configuration2-2.9.0.jar
|
||||||
file.reference.apache-commons-lang3-3.12.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-lang3-3.12.0.jar
|
file.reference.apache-commons-lang3-3.12.0.jar=lib\\apache-commons-lang3-3.12.0.jar
|
||||||
file.reference.apache-commons-logging-1.2.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-logging-1.2.jar
|
file.reference.apache-commons-logging-1.2.jar=lib\\apache-commons-logging-1.2.jar
|
||||||
file.reference.argon2-jvm-nolibs-2.11.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\argon2-jvm-nolibs-2.11.jar
|
file.reference.snmp4j-3.8.2.jar=lib\\snmp4j-3.8.2.jar
|
||||||
file.reference.spring-security-crypto-5.8.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\spring-security-crypto-5.8.0.jar
|
file.reference.spring-security-crypto-5.8.0.jar=lib\\spring-security-crypto-5.8.0.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${file.reference.apache-commons-configuration2-2.9.0.jar}:\
|
${file.reference.apache-commons-configuration2-2.9.0.jar}:\
|
||||||
${file.reference.apache-commons-lang3-3.12.0.jar}:\
|
${file.reference.apache-commons-lang3-3.12.0.jar}:\
|
||||||
${file.reference.spring-security-crypto-5.8.0.jar}:\
|
|
||||||
${file.reference.apache-commons-logging-1.2.jar}:\
|
${file.reference.apache-commons-logging-1.2.jar}:\
|
||||||
${file.reference.argon2-jvm-nolibs-2.11.jar}
|
${file.reference.spring-security-crypto-5.8.0.jar}:\
|
||||||
|
${file.reference.snmp4j-3.8.2.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,12 @@ public class Message implements Serializable {
|
||||||
// C->S: klient odesila upravu serveru
|
// C->S: klient odesila upravu serveru
|
||||||
public static final int SERVER_CONFIG = 13;
|
public static final int SERVER_CONFIG = 13;
|
||||||
|
|
||||||
//S->C: server odesila seznam objektu
|
// C->S: klient posila požadavek na restart serveru
|
||||||
public static final int OBJECT_LIST = 14;
|
public static final int RESTART = 15;
|
||||||
|
|
||||||
|
|
||||||
|
// C->S: klient se dotazuje na uptime server
|
||||||
|
// S->C: server odesila uptim serveru
|
||||||
|
public static final int UPTIME = 16;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,30 @@
|
||||||
package jnet.lib;
|
package jnet.lib;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.io.InputStream;
|
||||||
import java.util.logging.Logger;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
|
|
||||||
public class PropertiesManager {
|
public class PropertiesManager {
|
||||||
|
|
||||||
private PropertiesConfiguration config;
|
private PropertiesConfiguration config;
|
||||||
private String filePath;
|
private String file;
|
||||||
|
|
||||||
// Konstruktor pro inicializaci s cestou k souboru
|
// Konstruktor pro inicializaci s cestou k souboru
|
||||||
public PropertiesManager(String filePath) {
|
public PropertiesManager(String file) {
|
||||||
this.filePath = filePath;
|
this.file = file;
|
||||||
this.config = new PropertiesConfiguration();
|
this.config = new PropertiesConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() throws FileException, ConfigException {
|
public void load() throws FileException, ConfigException {
|
||||||
try {
|
try (InputStream input = getClass().getClassLoader().getResourceAsStream(file)) {
|
||||||
// Načtení existující konfigurace, pokud soubor existuje
|
if (input == null) {
|
||||||
config.read(new FileReader(filePath));
|
throw new FileException("Soubor config.properties nebyl nalezen.");
|
||||||
|
}
|
||||||
|
config.read(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||||
} catch (ConfigurationException ex) {
|
} catch (ConfigurationException ex) {
|
||||||
throw new ConfigException("Chyba konfigurace");
|
throw new ConfigException("Chyba konfigurace");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
@ -43,7 +44,7 @@ public class PropertiesManager {
|
||||||
|
|
||||||
// Metoda pro uložení konfigurace do souboru
|
// Metoda pro uložení konfigurace do souboru
|
||||||
public void save() {
|
public void save() {
|
||||||
try (FileWriter writer = new FileWriter(filePath)) {
|
try (FileWriter writer = new FileWriter(file)) {
|
||||||
// Použití FileWriter pro zápis do souboru
|
// Použití FileWriter pro zápis do souboru
|
||||||
config.write(writer);
|
config.write(writer);
|
||||||
LogFile.printInfo("Konfigurace byla uspesne ulozena.");
|
LogFile.printInfo("Konfigurace byla uspesne ulozena.");
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,21 @@ import jnet.lib.Status;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author cucky
|
|
||||||
*/
|
|
||||||
public class Map implements Serializable {
|
public class Map implements Serializable {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean lock;
|
private boolean lock;
|
||||||
//private ArrayList<MapObject> objects;
|
private ArrayList<MapObject> objects;
|
||||||
private int status;
|
private int status;
|
||||||
|
|
||||||
public Map(int id, String name, boolean lock) {
|
public Map(int id, String name, boolean lock, ArrayList<MapObject> objects) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
this.status = Status.NA;
|
this.status = Status.NA;
|
||||||
|
this.objects = objects;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map(String name) {
|
public Map(String name) {
|
||||||
|
|
@ -29,8 +27,6 @@ public class Map implements Serializable {
|
||||||
this.status = Status.NA;
|
this.status = Status.NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
@ -55,5 +51,36 @@ public class Map implements Serializable {
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<MapObject> getObjects() {
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObjects(ArrayList<MapObject> objects) {
|
||||||
|
this.objects = objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
if (getObjects().isEmpty()) {
|
||||||
|
return Status.NA;
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = Status.OK;
|
||||||
|
|
||||||
|
for (MapObject object : getObjects()) {
|
||||||
|
int objectStatus = object.getStatus();
|
||||||
|
|
||||||
|
if (objectStatus == Status.OFFLINE) {
|
||||||
|
return Status.OFFLINE; // Okamžitě vrátíme OFFLINE
|
||||||
|
} else if (objectStatus == Status.WARNING) {
|
||||||
|
status = Status.WARNING; // Možný downgrade na WARNING
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,28 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class ServerConfig implements Serializable {
|
public class ServerConfig implements Serializable {
|
||||||
|
|
||||||
|
private int pingRepeat;
|
||||||
private int pingAttempt;
|
private int pingAttempt;
|
||||||
private int pingTimeout;
|
private int pingTimeout;
|
||||||
private int instabilityAttempt;
|
private int instabilityAttempt;
|
||||||
private int instabilityLimit;
|
private int instabilityLimit;
|
||||||
|
|
||||||
public ServerConfig(int pingAttempt, int pingTimeout, int instabilityAttempt, int instabilityLimit) {
|
public ServerConfig(int pingRepeat, int pingAttempt, int pingTimeout, int instabilityAttempt, int instabilityLimit) {
|
||||||
|
this.pingRepeat = pingRepeat;
|
||||||
this.pingAttempt = pingAttempt;
|
this.pingAttempt = pingAttempt;
|
||||||
this.pingTimeout = pingTimeout;
|
this.pingTimeout = pingTimeout;
|
||||||
this.instabilityAttempt = instabilityAttempt;
|
this.instabilityAttempt = instabilityAttempt;
|
||||||
this.instabilityLimit = instabilityLimit;
|
this.instabilityLimit = instabilityLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPingRepeat() {
|
||||||
|
return pingRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPingRepeat(int pingRepeat) {
|
||||||
|
this.pingRepeat = pingRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPingAttempt() {
|
public int getPingAttempt() {
|
||||||
return pingAttempt;
|
return pingAttempt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue