public RegistrationHeartbeatResponse heartbeat(final String applicationId) { for (int i = 0; i < apiCallRetryLimit; i++) { if (i != 0) apiCallRetryTime.sleep(); // wait before we try again try { return service.heartbeatApplication(applicationId); } catch (Exception e) { log.warn("Index service heartbeat failed", e); } } // Try one last time without failure catching logic return service.heartbeatApplication(applicationId); }
public RegistrationResponse register(final RegistrationRequest request) { for (int i = 0; i < apiCallRetryLimit; i++) { if (i != 0) apiCallRetryTime.sleep(); // wait before we try again try { return service.registerApplication(request); } catch (Exception e) { log.warn("Index service register failed", e); } } // Try one last time without failure catching logic return service.registerApplication(request); }
/** * Try to find services, automatically retrying in the case of a communication failure * * @param iface * @return */ public List<ServiceDescription> findServices(Class<?> iface) { final ServiceSearchRequest request = new ServiceSearchRequest(); request.iface = iface.getName(); for (int i = 0; i < apiCallRetryLimit; i++) { if (i != 0) apiCallRetryTime.sleep(); // wait before we try again try { final ServiceSearchResults results = service.searchForServices(request); return results.services; } catch (Exception e) { log.warn("Index service search failed", e); } } // Try one last time without failure catching logic final ServiceSearchResults results = service.searchForServices(request); return results.services; }
/** * Try to unregister without any retry on failure * * @param applicationId */ public void unregister(final String applicationId) { service.deleteApplication(applicationId); }