Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public List<Backend> register(@RequestParam(value = "endpoint") String endpoint)
if ((newBackend = apiGateway.getFromRemote(endpointUrl)) != null) {
// TODO: BackendId should not be fetched from remote. For now I replace the remote one with the local one.
newBackend.setId(endpoint);

// Register the new backend
apiGateway.add(endpoint, endpointUrl);
dataGateway.add(endpoint, endpointUrl);
Expand Down Expand Up @@ -119,6 +120,15 @@ public List<Backend> unregister(@RequestParam(value = "endpointName") String end
@RequestMapping(method = RequestMethod.GET, value = "/list", produces = "application/json")
public List<Backend> getAll() {
logger.info("Backends: getAll");

// refresh backend metadata
for (String endpoint : registeredBackends.keySet()) {
Backend updatedBackend = apiGateway.getFromLocal(endpoint);
updatedBackend.setId(endpoint);
registeredBackends.put(endpoint, updatedBackend);
logger.info("Backend {} updated from server: ({}) ", endpoint, updatedBackend);
}

return new ArrayList<Backend>(registeredBackends.values());
}
}