I implemented that way but, i got a surprice.
At the beggining the program ran for 5 minits AND throw the next error:
V [libjvm.so+0x7feed4] IndexSetIterator::advance_and_next()+0xb4
AND no More explanation of why JVM brokes.
My surprise, begins from now, the program its running ay the moment without crashing from Yesterday …
Ok, here Is the code, thanks. I hope ur feedback.
The structure :
`public class MachineDAO {
private static final HashMap<String, Machine> activeMachines;
static{
activeMachines = new HashMap<>();
}
public int insertar(String serialNumber, Machine m) {
activeMachines.put(serialNumber,m);
return activeMachines.size();
}
public Machine getMachineBySerialNumber(String sn) {
return activeMachines.get(sn);
}
public boolean existsMachine(String id) {
return activeMachines.containsKey(id);
}
public boolean eliminar(int id){
return activeMachines.remove(id)!= null;
}
}`
AND the múltiple concurrent tasks..
`public static Route publicar = (Request request, Response response) -> {`
String msgJson = request.body();
Wagered wagered = lecturaJSON(msgJson); //no matter
MachineDAO mDAO = new MachineDAO(); //yes matter
if( mDAO.existsMachine(wagered.getSerialNumber())){ //yes matter
Machine m = mDAO.getMachineBySerialNumber(wagered.getSerialNumber()); //yes matter
publicarWageredToBroker(wagered,m); // no matter
response.type("application/json");// no matter
response.status(200);// no matter
response.body(wagered.toJsonConfig(m).toString());// no matter
}else{
response.type("application/json");
response.status(400);
response.body("{"error":"No pudimos encontrar ningun registro asociado con el id. "+ wagered.getMachineId() +", no se ha publicado nada al broker." }");
}
return response.body();
};
…………ok thats it.
Apendix (my spark API config):
threadPool(500, 32, 30000);
post(“/delivery/wagered”, WageredController.publicar);
I’m waiting ir answers
I expect new AND creative ways of hanndle this problem, it Is simply but are a lots of threads interacting with my hashmap. (The most of the cases Will be for ask for existence of an elemento, AND un some cases, some insertions. Thanks u bay.
1