Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #382 from OpenSRP/path_issue379
Browse files Browse the repository at this point in the history
PATH: Fix issue of duplicate server versions
  • Loading branch information
Ephraim (Keyman) Muhia authored Feb 27, 2018
2 parents f7e534c + c94f8ed commit 704dc67
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,22 @@ public void processEvent() {
}
}

private void addServerVersion() {
private synchronized void addServerVersion() {
try {
List<Client> clients = allClients.findByEmptyServerVersion();
long currentTimeMillis = getCurrentMilliseconds();
while (clients != null && !clients.isEmpty()) {
for (Client client : clients) {
try {
Thread.sleep(1);
client.setServerVersion(getCurrentMilliseconds());
client.setServerVersion(currentTimeMillis);
allClients.update(client);
logger.debug("Add server_version: found new client " + client.getBaseEntityId());
}
catch (InterruptedException e) {
logger.error("", e);
}
currentTimeMillis += 1;
}
clients = allClients.findByEmptyServerVersion();
}
Expand All @@ -141,14 +143,15 @@ private void addServerVersion() {
try {
Thread.sleep(1);
event = eventService.processOutOfArea(event);
event.setServerVersion(getCurrentMilliseconds());
event.setServerVersion(currentTimeMillis);
allEvents.update(event);

logger.debug("Add server_version: found new event " + event.getBaseEntityId());
}
catch (InterruptedException e) {
logger.error("", e);
}
currentTimeMillis += 1;
}

events = allEvents.findByEmptyServerVersion();
Expand Down

0 comments on commit 704dc67

Please sign in to comment.