Merge branch 'benjamin' into dev
This commit is contained in:
commit
b33385355d
@ -19,14 +19,11 @@ public class FFETimer extends TimerTask {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Timer 1");
|
||||
for (String domain : processorRepository.getDomains()) {
|
||||
LocalDateTime lastAnnounce = processorRepository.getLastAnnounce(domain);
|
||||
long secondBetween = Math.abs(ChronoUnit.SECONDS.between(lastAnnounce, LocalDateTime.now()));
|
||||
|
||||
System.out.println("Timer 2 : " + secondBetween);
|
||||
if (secondBetween > 50) {
|
||||
System.out.println("Timer 3");
|
||||
processorRepository.closeStore(domain);
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public class StoreProcessor extends Thread implements AutoCloseable {
|
||||
if (responseCommand == null) {
|
||||
this.close();
|
||||
}
|
||||
fileFrontEnd.onStoreAvailable(this, responseCommand);
|
||||
fileFrontEnd.onStoreAvailable(this.getDomain(), responseCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ public class StoreProcessor extends Thread implements AutoCloseable {
|
||||
public void close() {
|
||||
if (this.client_run) {
|
||||
this.client_run = false;
|
||||
System.out.println("[FERMETURE SBE] " + domain);
|
||||
System.out.println("[SBE] Fermeture de " + domain);
|
||||
// TODO : Gérer déconnection (enlever du repo et prévenir client et FileFrontEnd)
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ public interface StoreProcessorFFE {
|
||||
/**
|
||||
* Allows a {@link StoreProcessor} to notify the FFE that it's available.
|
||||
*
|
||||
* @param store The store processor that is now available.
|
||||
* @param storeDomain The store processor that is now available.
|
||||
* @param response
|
||||
*/
|
||||
void onStoreAvailable(StoreProcessor store, ProtocolWriter.ProtocolResult response);
|
||||
void onStoreAvailable(String storeDomain, ProtocolWriter.ProtocolResult response);
|
||||
|
||||
/**
|
||||
* Permet de déconnecter un SBE
|
||||
|
@ -3,7 +3,6 @@ package lightcontainer.repository;
|
||||
import lightcontainer.domains.client.Context;
|
||||
import lightcontainer.domains.client.StoreProcessor;
|
||||
import lightcontainer.domains.Task;
|
||||
import lightcontainer.enumerations.TaskStatus;
|
||||
import lightcontainer.interfaces.ClientHandlerFFE;
|
||||
import lightcontainer.interfaces.ProtocolRepository;
|
||||
import lightcontainer.interfaces.StoreProcessorFFE;
|
||||
@ -42,37 +41,38 @@ public class FileFrontEnd implements ClientHandlerFFE, StoreProcessorFFE {
|
||||
/**
|
||||
* Permet à un {@link StoreProcessor} d'avertir le FFE qu'il est disponible
|
||||
*
|
||||
* @param store Le SBE qui s'est occupé de la tâche
|
||||
* @param storeDomain Le SBE qui s'est occupé de la tâche
|
||||
* @param response La réponse à envoyer au client
|
||||
*/
|
||||
@Override
|
||||
public void onStoreAvailable(StoreProcessor store, ProtocolWriter.ProtocolResult response) {
|
||||
public void onStoreAvailable(String storeDomain, ProtocolWriter.ProtocolResult response) {
|
||||
responseToClient(storeDomain, response);
|
||||
|
||||
Iterator<Task> it = tasks.iterator();
|
||||
while (it.hasNext()) {
|
||||
Task task = it.next();
|
||||
if (task.isResponseOfClient(store.getDomain())) {
|
||||
clientRepository.respondToClient(task.getClient(), response);
|
||||
it.remove(); // Suppression de la tâche
|
||||
break;
|
||||
if (task.getDomain() == null) {
|
||||
task.setDomain(storeDomain);
|
||||
storeRepository.assignTask(storeDomain, task);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assignOtherTask(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStoreDisconnect(String domain) {
|
||||
responseToClient(domain, null);
|
||||
this.storeRepository.closeStore(domain);
|
||||
}
|
||||
|
||||
private void assignOtherTask(StoreProcessor store) {
|
||||
private void responseToClient(String storeDomain, ProtocolWriter.ProtocolResult response) {
|
||||
Iterator<Task> it = tasks.iterator();
|
||||
while (it.hasNext()) {
|
||||
Task task = it.next();
|
||||
if (task.getDomain() == null && store.canProcessTask()) {
|
||||
task.setDomain(store.getDomain());
|
||||
store.executeCommand(task.getContext(), task.getCommand());
|
||||
return;
|
||||
if (task.isResponseOfClient(storeDomain)) {
|
||||
clientRepository.respondToClient(task.getClient(), response);
|
||||
it.remove(); // Suppression de la tâche
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +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": "aaaaa",
|
||||
"password": "$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W",
|
||||
"aes_key": "kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=",
|
||||
"files": [
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{"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":"aaaaa","password":"$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W","aes_key":"kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=","files":[{"name":"README.md","fileNameSalt":"4m84wYD79s9FoFq7Tqjzow==","size":17,"iv":"8EaBv4WGO++knjUbLXSFUA==","storage":["lightcontainerSB01"]}]}]}
|
Loading…
Reference in New Issue
Block a user