- Ajout possibilité de faire attendre une tâche après un SBE

This commit is contained in:
Benjamin 2022-03-19 14:10:50 +01:00
parent 6a002327db
commit 308bc783ac
4 changed files with 20 additions and 49 deletions

View File

@ -79,9 +79,12 @@ public class StoreProcessor extends Thread implements AutoCloseable {
@Override
public void run() {
this.client_run = true;
while (this.client_run) {
try {
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
}

View File

@ -68,12 +68,11 @@ public class FileFrontEnd implements ClientHandlerFFE, StoreProcessorFFE {
private void assignOtherTask(StoreProcessor store) {
Iterator<Task> 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;
}
}

View File

@ -75,12 +75,23 @@ 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);
StoreProcessor handler = getSBE(stor);
if (handler != null) {
handler.executeCommand(task.getContext(), task.getCommand());
}
}
@Override
public boolean hasDomain(String domain) {

View File

@ -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"
]
}
]
}
]
}
{"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"]}]}]}