Skip to content

Commit

Permalink
if existing node list is empty and fetch node list is empty, refresh …
Browse files Browse the repository at this point in the history
…service registry
  • Loading branch information
Jitendra Dhawan committed Jun 19, 2024
1 parent 936c214 commit 12c80d2
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import io.appform.ranger.core.model.ServiceRegistry;
import io.appform.ranger.core.signals.Signal;
import io.appform.ranger.core.util.Exceptions;
import java.util.Collections;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import lombok.val;

Expand Down Expand Up @@ -138,8 +140,17 @@ private void updateRegistry() throws InterruptedException {
serviceRegistry.updateNodes(nodeList);
}
else {
log.warn("Empty list returned from node data source. We are in a weird state. Keeping old list for {}",
serviceRegistry.getService().getServiceName());
// if existing node list is null or empty, just refresh it with empty list again
// to set the atomic boolean flag : refreshed as true
if(Objects.isNull(serviceRegistry.nodeList()) || serviceRegistry.nodeList().isEmpty()){
log.debug("Empty list returned from node data source. Old list for {} was empty and refreshing it again with empty list",
serviceRegistry.getService().getServiceName());
serviceRegistry.updateNodes(Collections.emptyList());
} else {
// if existing node list is not null or not empty, retain it as it is
log.warn("Empty list returned from node data source. We are in a weird state. Keeping old list for {}",
serviceRegistry.getService().getServiceName());
}
}
}

Expand Down

0 comments on commit 12c80d2

Please sign in to comment.