In one of the pull request I mistakenly swapped the way replicas are added to the ConcurrentHashMap.
In PlaceManager.addReplica() was using replicas.replace(FullAddress, Date) and should be using replicas.put(FullAddress, Date).
The .replace implementation doesn't add a <k,v> if doesn't exist.
This meant that replicas.size() was always 0 so, the server would always get the majority since it voted for himself. 1 > size [0] / 2 == true, always.
Changed how starting the server works
Server now expects 4 arguments (was 3 before).
Multicast Address
Multicast Port
Server Address (normally 127.0.0.1)
Server Port
Updated Dockerfile to account for these changes.
File restructure
Swapped ComunicationMessage to ComunicationHeartbeat everywhere ComunicationMessage was referenced.
Updated serialVersion of Serializable objects.
Changed PlaceManager.newTimeout() to receive the min and max timeout possible values.
Removed synchronized from methods that used to access ConcurrentHashMap of PlaceManager, since concurrency is already handled at class level, and adding another level lock is, not only ambiguous, but also potentially harmful.
Fixed #17!
ConcurrentHashMap
.PlaceManager.addReplica()
was usingreplicas.replace(FullAddress, Date)
and should be usingreplicas.put(FullAddress, Date)
..replace
implementation doesn't add a<k,v>
if doesn't exist.replicas.size()
was always0
so, the server would always get the majority since it voted for himself. 1 > size [0] / 2 == true, always.Changed how starting the server works
File restructure
ComunicationMessage
toComunicationHeartbeat
everywhereComunicationMessage
was referenced.serialVersion
of Serializable objects.PlaceManager.newTimeout()
to receive themin
andmax
timeout possible values.synchronized
from methods that used to accessConcurrentHashMap
ofPlaceManager
, since concurrency is already handled at class level, and adding another level lock is, not only ambiguous, but also potentially harmful.JavaDocs