예제 #1
0
  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);
  }
예제 #2
0
  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);
  }
예제 #3
0
  /**
   * 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;
  }
예제 #4
0
 /**
  * Try to unregister without any retry on failure
  *
  * @param applicationId
  */
 public void unregister(final String applicationId) {
   service.deleteApplication(applicationId);
 }