コード例 #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);
 }