diff --git a/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java b/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java index 7a90ddf..80c49e0 100644 --- a/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java +++ b/app/src/main/java/lightcontainer/domains/client/StoreProcessor.java @@ -79,9 +79,12 @@ public class StoreProcessor extends Thread implements AutoCloseable { @Override public void run() { this.client_run = true; + while (this.client_run) { try { - waitAction(); + if (protocolResult == null) { // Si on n'a pas encore la commande à envoyer + waitAction(); + } System.out.println("[SBE] Envoie commande : " + protocolResult.getCommand()); // Request @@ -209,7 +212,6 @@ public class StoreProcessor extends Thread implements AutoCloseable { } public boolean canProcessTask() { - System.out.println("[OK 2] " + protocolResult + " - " + domain); return this.protocolResult == null; // Vérifier si tâche veut ce SBE } diff --git a/app/src/main/java/lightcontainer/repository/FileFrontEnd.java b/app/src/main/java/lightcontainer/repository/FileFrontEnd.java index b816212..b808ff0 100644 --- a/app/src/main/java/lightcontainer/repository/FileFrontEnd.java +++ b/app/src/main/java/lightcontainer/repository/FileFrontEnd.java @@ -68,12 +68,11 @@ public class FileFrontEnd implements ClientHandlerFFE, StoreProcessorFFE { private void assignOtherTask(StoreProcessor store) { Iterator it = tasks.iterator(); - while (it.hasNext()) { Task task = it.next(); if (task.getDomain() == null && store.canProcessTask()) { - storeRepository.assignTask(store.getDomain(), task); task.setDomain(store.getDomain()); + store.executeCommand(task.getContext(), task.getCommand()); return; } } diff --git a/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java b/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java index 78783d6..5a3b617 100644 --- a/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java +++ b/app/src/main/java/lightcontainer/repository/StoreProcessorRepository.java @@ -75,11 +75,22 @@ public class StoreProcessorRepository implements AutoCloseable, MulticastSPR { return null; } + private StoreProcessor getSBE(String stor) { + for (StoreProcessor handler : handlers) { + if (handler.getDomain().equals(stor)) { + return handler; + } + } + + return null; + } + @Override public void assignTask(String stor, Task task) { - StoreProcessor handler = findSBE(); - System.out.println("Find stor : " + handler); - handler.executeCommand(task.getContext(), task.getCommand()); + StoreProcessor handler = getSBE(stor); + if (handler != null) { + handler.executeCommand(task.getContext(), task.getCommand()); + } } @Override diff --git a/app/src/main/resources/appdata.json b/app/src/main/resources/appdata.json index c053453..5cd8dca 100644 --- a/app/src/main/resources/appdata.json +++ b/app/src/main/resources/appdata.json @@ -1,42 +1 @@ -{ - "unicast_port": 8000, - "multicast_ip": "224.66.66.1", - "multicast_port": 15502, - "network_interface": "wlp1s0", - "tls": true, - "storagePath": "/home/benjamin/ffe", - "users": [ - { - "name": "benjamin", - "password": "$2a$10$I4vHt83CTYuQCP7xvZ04Ne7Vb0cswBiVZhV0n23k9FCxoH0ny9fZG", - "aes_key": "mAP6izUBUhBxIkakH2yB/TplhRz1OQV5Fp6HQmhywns=", - "files": [ - { - "name": "README.md", - "fileNameSalt": "5k8bd3/hn5ehdkCRJ0MGRQ==", - "size": 17, - "iv": "/sEVBG7kKnMaJcg5Wpz2bQ==", - "storage": [ - "lightcontainerSB02" - ] - } - ] - }, - { - "name": "aaaaa", - "password": "$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W", - "aes_key": "kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=", - "files": [ - { - "name": "ca.crt", - "fileNameSalt": "JmISh065QAtDIePgl8IG2A==", - "size": 4207, - "iv": "Tg3aeOm1U0hQI1VqSZbAJw==", - "storage": [ - "lightcontainerSB01" - ] - } - ] - } - ] -} \ No newline at end of file +{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"wlp1s0","tls":true,"storagePath":"/home/benjamin/ffe","users":[{"name":"benjamin","password":"$2a$10$I4vHt83CTYuQCP7xvZ04Ne7Vb0cswBiVZhV0n23k9FCxoH0ny9fZG","aes_key":"mAP6izUBUhBxIkakH2yB/TplhRz1OQV5Fp6HQmhywns=","files":[{"name":"README.md","fileNameSalt":"atK0eGo/J8IBOTCpIZpWow==","size":17,"iv":"fXPzefxl0cO4Hf02Qwi+BA==","storage":["lightcontainerSB01"]}]},{"name":"aaaaa","password":"$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W","aes_key":"kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=","files":[{"name":"ca.crt","fileNameSalt":"qz6FoPGyJJ8Hy+1LIouvZA==","size":4207,"iv":"8v2H+cOzztD++NXHXw5Ofw==","storage":["lightcontainerSB01"]}]}]} \ No newline at end of file