parent
da70ff117b
commit
bd25e36f72
|
@ -49,29 +49,23 @@ public class AgentService {
|
|||
}
|
||||
|
||||
public boolean addAgentToPool(Agent agentWithoutId) {
|
||||
/* synchronized (this.getAgentRepository().getAddDeleteLock()) {*/
|
||||
if (!this.getAgentRepository().attach(
|
||||
Agent.createAgentWithoutId(agentWithoutId))) {
|
||||
return false;
|
||||
}
|
||||
Agent agent = this.getAgentRepository().getAgentBy(
|
||||
agentWithoutId.getHostName());
|
||||
if (agent == null) {
|
||||
return false;
|
||||
}
|
||||
this.getHighAvailablePool().add(agent);
|
||||
return true;
|
||||
// }
|
||||
|
||||
if (!this.getAgentRepository().attach(
|
||||
Agent.createAgentWithoutId(agentWithoutId))) {
|
||||
return false;
|
||||
}
|
||||
Agent agent = this.getAgentRepository().getAgentBy(
|
||||
agentWithoutId.getHostName());
|
||||
if (agent == null) {
|
||||
return false;
|
||||
}
|
||||
this.getHighAvailablePool().add(agent);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeAgentFromPool(int agentId) {
|
||||
// TODO: check if the agent is idle
|
||||
// synchronized (this.getAgentRepository().getAddDeleteLock()) {
|
||||
this.getHighAvailablePool().remove(
|
||||
getAgentRepository().getEntity(agentId));
|
||||
return this.getAgentRepository().detach(agentId);
|
||||
// }
|
||||
this.getHighAvailablePool().remove(
|
||||
getAgentRepository().getEntity(agentId));
|
||||
return this.getAgentRepository().detach(agentId);
|
||||
}
|
||||
|
||||
public List<Agent> loadAgentPoolFromDB() {
|
||||
|
|
Loading…
Reference in New Issue