Trompé en allant sur dev
This commit is contained in:
parent
c6f8025d4b
commit
b10f1edf54
@ -178,4 +178,8 @@ public class ClientHandler implements Runnable, AutoCloseable {
|
|||||||
} catch (IOException ignored) { }
|
} catch (IOException ignored) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return this.login;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package lightcontainer.domains.client;
|
package lightcontainer.domains.client;
|
||||||
|
|
||||||
|
import lightcontainer.domains.Task;
|
||||||
import lightcontainer.interfaces.ProtocolRepository;
|
import lightcontainer.interfaces.ProtocolRepository;
|
||||||
import lightcontainer.interfaces.StoreProcessorFFE;
|
import lightcontainer.interfaces.StoreProcessorFFE;
|
||||||
import lightcontainer.protocol.ProtocolReader;
|
import lightcontainer.protocol.ProtocolReader;
|
||||||
@ -170,4 +171,8 @@ public class StoreProcessor extends Thread implements AutoCloseable {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(domain);
|
return Objects.hash(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canProcessTask(Task task) {
|
||||||
|
return this.currentCommand == null; // Vérifier si tâche veut ce SBE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package lightcontainer.interfaces;
|
package lightcontainer.interfaces;
|
||||||
|
|
||||||
|
import lightcontainer.domains.Task;
|
||||||
import lightcontainer.domains.client.StoreProcessor;
|
import lightcontainer.domains.client.StoreProcessor;
|
||||||
import lightcontainer.domains.server.MulticastServerListener;
|
import lightcontainer.domains.server.MulticastServerListener;
|
||||||
import lightcontainer.repository.StoreProcessorRepository;
|
import lightcontainer.repository.StoreProcessorRepository;
|
||||||
@ -19,4 +20,6 @@ public interface MulticastSPR {
|
|||||||
* @param store Store processor to add.
|
* @param store Store processor to add.
|
||||||
*/
|
*/
|
||||||
void addStore(StoreProcessor store);
|
void addStore(StoreProcessor store);
|
||||||
|
|
||||||
|
String findSBE(Task task);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,10 @@ public class ClientHandlerRepository implements AutoCloseable, UnicastCHR {
|
|||||||
@Override
|
@Override
|
||||||
public void respondToClient(String login, ProtocolWriter.ProtocolResult response) {
|
public void respondToClient(String login, ProtocolWriter.ProtocolResult response) {
|
||||||
for (ClientHandler client : handlers) {
|
for (ClientHandler client : handlers) {
|
||||||
client.respond(response);
|
if (client.getLogin().equals(login)) {
|
||||||
|
client.respond(response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public class FileFrontEnd implements ClientHandlerFFE, StoreProcessorFFE {
|
|||||||
*/
|
*/
|
||||||
public void alertStoreProcessors(Task task) {
|
public void alertStoreProcessors(Task task) {
|
||||||
// On avertit les stor processors d'une nouvelle tâche
|
// On avertit les stor processors d'une nouvelle tâche
|
||||||
|
String stor = storeRepository.findSBE(task);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,5 +59,6 @@ public class FileFrontEnd implements ClientHandlerFFE, StoreProcessorFFE {
|
|||||||
// TODO : Ajouter la tâche - Alerter les StorBackEnds
|
// TODO : Ajouter la tâche - Alerter les StorBackEnds
|
||||||
Task task = Task.newInstance(command, client);
|
Task task = Task.newInstance(command, client);
|
||||||
tasks.add(task);
|
tasks.add(task);
|
||||||
|
alertStoreProcessors(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package lightcontainer.repository;
|
package lightcontainer.repository;
|
||||||
|
|
||||||
|
import lightcontainer.domains.Task;
|
||||||
import lightcontainer.domains.client.StoreProcessor;
|
import lightcontainer.domains.client.StoreProcessor;
|
||||||
import lightcontainer.domains.server.MulticastServerListener;
|
import lightcontainer.domains.server.MulticastServerListener;
|
||||||
import lightcontainer.interfaces.MulticastSPR;
|
import lightcontainer.interfaces.MulticastSPR;
|
||||||
@ -53,6 +54,18 @@ public class StoreProcessorRepository implements AutoCloseable, MulticastSPR {
|
|||||||
this.handlers.add(store);
|
this.handlers.add(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String findSBE(Task task) {
|
||||||
|
|
||||||
|
for (StoreProcessor handler : handlers) {
|
||||||
|
if (handler.canProcessTask(task)) {
|
||||||
|
return handler.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AutoClosable Function
|
* AutoClosable Function
|
||||||
* Closes all StoreProcessor stored in this repository and deallocates all resources.
|
* Closes all StoreProcessor stored in this repository and deallocates all resources.
|
||||||
|
Loading…
Reference in New Issue
Block a user