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