Amélioration : Deux SBE de même domaine et ports différents ne peuvent plus être connectés en même temps
This commit is contained in:
parent
e5628942a2
commit
20c5697301
@ -45,7 +45,6 @@ public class StoreProcessor extends Thread implements AutoCloseable {
|
||||
this.store = socket;
|
||||
this.protocolRep = protocolRep;
|
||||
this.client_run = false;
|
||||
initStore();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +54,7 @@ public class StoreProcessor extends Thread implements AutoCloseable {
|
||||
* @see PrintWriter
|
||||
* @since 1.0
|
||||
*/
|
||||
private void initStore() {
|
||||
public void startStore() {
|
||||
try {
|
||||
this.reader = new BufferedReader(new InputStreamReader(
|
||||
this.store.getInputStream(),
|
||||
|
@ -70,6 +70,7 @@ public class MulticastServerListener implements Runnable {
|
||||
HelloRule.Result readerResult = protocolRep.executeReader(null, data);
|
||||
System.out.printf("Nouveau SBE : Domain=%s | Port=%d\n", readerResult.getDomain(), readerResult.getPort());
|
||||
|
||||
if (!this.repository.hasDomain(readerResult.getDomain())){
|
||||
Socket socket = new Socket(packet.getAddress(), readerResult.getPort());
|
||||
|
||||
// Create the store processor
|
||||
@ -77,6 +78,7 @@ public class MulticastServerListener implements Runnable {
|
||||
|
||||
// Add the store processor to its repository
|
||||
this.repository.addStore(storeProcessor);
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public interface MulticastSPR {
|
||||
* Add a StorePorcessor.
|
||||
* @param store Store processor to add.
|
||||
*/
|
||||
void addStore(StoreProcessor store);
|
||||
boolean addStore(StoreProcessor store);
|
||||
|
||||
String findDomain(Task task);
|
||||
|
||||
|
@ -50,9 +50,12 @@ public class StoreProcessorRepository implements AutoCloseable, MulticastSPR {
|
||||
* @since 1.0
|
||||
*/
|
||||
@Override
|
||||
public void addStore(StoreProcessor store) {
|
||||
this.handlers.add(store);
|
||||
|
||||
public boolean addStore(StoreProcessor store) {
|
||||
if (!this.hasDomain(store.getDomain())) {
|
||||
store.startStore();
|
||||
return this.handlers.add(store);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1 +1,43 @@
|
||||
{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"My network interface","tls":true,"storagePath":"/home/benjamin/ffe","users":[{"name":"aaaaa","password":"5d628c274ebb008324f1e199d3bfff0a3fe839730a7f2355e82850d7acca5e5ca64db9071abf3d91034295695f84a617","aes_key":"qlTH6TijnfMRnrS0Qf+k6IPKGp5LoRMXGxCq16e+mF4=","passwordSalt":"Ns8Al6DpqPsIDlCSRBVTEg==","files":[{"name":"main.py","fileNameSalt":"IJNYL681pFqbF9OHzRuHIg==","size":854,"iv":"bPCnwYbenKvFfwbhq+HI5A==","storage":["lightcontainerSB01"]},{"name":"README.md","fileNameSalt":"/jo0zYyQs96gWI9OgBXiPQ==","size":17,"iv":"rvOFhgEvgFMISO44jqlSRg==","storage":["lightcontainerSB01"]}]}]}
|
||||
{
|
||||
"unicast_port": 8000,
|
||||
"multicast_ip": "224.66.66.1",
|
||||
"multicast_port": 15502,
|
||||
"network_interface": "My network interface",
|
||||
"tls": true,
|
||||
"storagePath": "/home/benjamin/ffe",
|
||||
"users": [
|
||||
{
|
||||
"name": "aaaaa",
|
||||
"password": "5d628c274ebb008324f1e199d3bfff0a3fe839730a7f2355e82850d7acca5e5ca64db9071abf3d91034295695f84a617",
|
||||
"aes_key": "qlTH6TijnfMRnrS0Qf+k6IPKGp5LoRMXGxCq16e+mF4=",
|
||||
"passwordSalt": "Ns8Al6DpqPsIDlCSRBVTEg==",
|
||||
"files": [
|
||||
{
|
||||
"name": "main.py",
|
||||
"fileNameSalt": "IJNYL681pFqbF9OHzRuHIg==",
|
||||
"size": 854,
|
||||
"iv": "bPCnwYbenKvFfwbhq+HI5A==",
|
||||
"storage": [
|
||||
"lightcontainerSB01"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "README.md",
|
||||
"fileNameSalt": "/jo0zYyQs96gWI9OgBXiPQ==",
|
||||
"size": 17,
|
||||
"iv": "rvOFhgEvgFMISO44jqlSRg==",
|
||||
"storage": [
|
||||
"lightcontainerSB01"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "test1",
|
||||
"password": "4348c6955fc61e81fd952e218734cb8af04df549adca990ad6bd7f46e983ebcc1ea6ddb1bee08db8c670100219597e92",
|
||||
"aes_key": "UZsJ6PT6WfKptNXIlY5vPnXkjlvL36Pq3z3vLdVl/5s=",
|
||||
"passwordSalt": "1a5BS3tyqpSSwvv/nTQcVA==",
|
||||
"files": []
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user