congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
DiscoveryException
Code IndexAdd Tabnine to your IDE (free)

How to use
DiscoveryException
in
io.airlift.discovery.client

Best Java code snippets using io.airlift.discovery.client.DiscoveryException (Showing top 20 results out of 315)

origin: airlift/airlift

  @Override
  public final T handleException(Request request, Exception exception)
  {
    if (exception instanceof InterruptedException) {
      throw new DiscoveryException(name + " was interrupted for " + uri);
    }
    if (exception instanceof CancellationException) {
      throw new DiscoveryException(name + " was canceled for " + uri);
    }
    if (exception instanceof DiscoveryException) {
      throw (DiscoveryException) exception;
    }
    throw new DiscoveryException(name + " failed for " + uri, exception);
  }
}
origin: airlift/airlift

@PreDestroy
public void destroy()
{
  executor.shutdownNow();
  try {
    executor.awaitTermination(30, SECONDS);
  }
  catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  // unannounce
  try {
    getFutureValue(announcementClient.unannounce(), DiscoveryException.class);
  }
  catch (DiscoveryException e) {
    if (e.getCause() instanceof ConnectException) {
      log.error("Cannot connect to discovery server for unannounce: %s", e.getCause().getMessage());
    }
    else {
      log.error(e);
    }
  }
}
origin: io.airlift/discovery-experimental

  @Override
  public void run()
  {
    Duration duration = DEFAULT_DELAY;
    try {
      duration = future.checkedGet();
      if (serverUp.compareAndSet(false, true)) {
        log.info("Discovery server connect succeeded for announce");
      }
    }
    catch (DiscoveryException e) {
      if (serverUp.compareAndSet(true, false)) {
        log.error("Cannot connect to discovery server for announce: %s", e.getMessage());
      }
      log.debug(e, "Cannot connect to discovery server for announce");
    }
    finally {
      scheduleNextAnnouncement(duration);
    }
  }
}, executor);
origin: com.teradata.airlift/discovery

@PreDestroy
public void destroy()
{
  executor.shutdownNow();
  try {
    executor.awaitTermination(30, SECONDS);
  }
  catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  // unannounce
  try {
    getFutureResult(announcementClient.unannounce(), DiscoveryException.class);
  }
  catch (DiscoveryException e) {
    if (e.getCause() instanceof ConnectException) {
      log.error("Cannot connect to discovery server for unannounce: %s", e.getCause().getMessage());
    }
    else {
      log.error(e);
    }
  }
}
origin: io.airlift/discovery-experimental

  @Override
  public void run()
  {
    Duration delay = DEFAULT_DELAY;
    try {
      ServiceDescriptors newDescriptors = future.checkedGet();
      delay = newDescriptors.getMaxAge();
      serviceDescriptors.set(newDescriptors);
      if (serverUp.compareAndSet(false, true)) {
        log.info("Discovery server connect succeeded for refresh (%s/%s)", type, pool);
      }
    }
    catch (DiscoveryException e) {
      if (serverUp.compareAndSet(true, false)) {
        log.error("Cannot connect to discovery server for refresh (%s/%s): %s", type, pool, e.getMessage());
      }
      log.debug(e, "Cannot connect to discovery server for refresh (%s/%s)", type, pool);
    }
    finally {
      scheduleRefresh(delay);
    }
  }
}, executor);
origin: airlift/airlift

  @Override
  public final T handleException(Request request, Exception exception)
  {
    if (exception instanceof InterruptedException) {
      throw new DiscoveryException(name + " was interrupted for " + uri);
    }
    if (exception instanceof CancellationException) {
      throw new DiscoveryException(name + " was canceled for " + uri);
    }
    if (exception instanceof DiscoveryException) {
      throw (DiscoveryException) exception;
    }
    throw new DiscoveryException(name + " failed for " + uri, exception);
  }
}
origin: io.airlift/discovery-experimental

@PreDestroy
public void destroy()
{
  executor.shutdownNow();
  try {
    executor.awaitTermination(30, TimeUnit.SECONDS);
  }
  catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  // unannounce
  try {
    announcementClient.unannounce().checkedGet();
  }
  catch (DiscoveryException e) {
    if (e.getCause() instanceof ConnectException) {
      log.error("Cannot connect to discovery server for unannounce: %s", e.getCause().getMessage());
    }
    else {
      log.error(e);
    }
  }
}
origin: io.airlift/discovery-experimental

  @Override
  public final DiscoveryException handleException(Request request, Exception exception)
  {
    if (exception instanceof InterruptedException) {
      return new DiscoveryException(name + " was interrupted");
    }
    if (exception instanceof CancellationException) {
      return new DiscoveryException(name + " was canceled");
    }
    if (exception instanceof DiscoveryException) {
      throw (DiscoveryException) exception;
    }
    return new DiscoveryException(name + " failed", exception);
  }
}
origin: io.airlift/discovery-experimental

  @Override
  public final DiscoveryException handleException(Request request, Exception exception)
  {
    if (exception instanceof InterruptedException) {
      return new DiscoveryException(name + " was interrupted");
    }
    if (exception instanceof CancellationException) {
      return new DiscoveryException(name + " was canceled");
    }
    if (exception instanceof DiscoveryException) {
      throw (DiscoveryException) exception;
    }
    return new DiscoveryException(name + " failed", exception);
  }
}
origin: com.teradata.airlift/discovery

  @Override
  public final T handleException(Request request, Exception exception)
  {
    if (exception instanceof InterruptedException) {
      throw new DiscoveryException(name + " was interrupted for " + uri);
    }
    if (exception instanceof CancellationException) {
      throw new DiscoveryException(name + " was canceled for " + uri);
    }
    if (exception instanceof DiscoveryException) {
      throw (DiscoveryException) exception;
    }
    throw new DiscoveryException(name + " failed for " + uri, exception);
  }
}
origin: com.teradata.airlift/discovery

  @Override
  public final T handleException(Request request, Exception exception)
  {
    if (exception instanceof InterruptedException) {
      throw new DiscoveryException(name + " was interrupted for " + uri);
    }
    if (exception instanceof CancellationException) {
      throw new DiscoveryException(name + " was canceled for " + uri);
    }
    if (exception instanceof DiscoveryException) {
      throw (DiscoveryException) exception;
    }
    throw new DiscoveryException(name + " failed for " + uri, exception);
  }
}
origin: io.airlift/discovery-experimental

  @Override
  public DiscoveryException apply(Exception e)
  {
    if (e instanceof InterruptedException) {
      Thread.currentThread().interrupt();
      return new DiscoveryException(name + " was interrupted");
    }
    if (e instanceof CancellationException) {
      return new DiscoveryException(name + " was canceled");
    }
    Throwable cause = e;
    if (e instanceof ExecutionException) {
      if (e.getCause() != null) {
        cause = e.getCause();
      }
    }
    if (cause instanceof DiscoveryException) {
      return (DiscoveryException) cause;
    }
    return new DiscoveryException(name + " failed", cause);
  }
});
origin: airlift/airlift

  @Override
  public Duration handle(Request request, Response response)
      throws DiscoveryException
  {
    int statusCode = response.getStatusCode();
    if (!isSuccess(statusCode)) {
      throw new DiscoveryException(String.format("Announcement failed with status code %s: %s", statusCode, getBodyForError(response)));
    }
    Duration maxAge = extractMaxAge(response);
    return maxAge;
  }
});
origin: com.teradata.airlift/discovery

  @Override
  public Duration handle(Request request, Response response)
      throws DiscoveryException
  {
    int statusCode = response.getStatusCode();
    if (!isSuccess(statusCode)) {
      throw new DiscoveryException(String.format("Announcement failed with status code %s: %s", statusCode, getBodyForError(response)));
    }
    Duration maxAge = extractMaxAge(response);
    return maxAge;
  }
});
origin: io.airlift/discovery-experimental

  @Override
  public Duration handle(Request request, Response response)
      throws DiscoveryException
  {
    int statusCode = response.getStatusCode();
    if (!isSuccess(statusCode)) {
      throw new DiscoveryException(String.format("Announcement failed with status code %s: %s", statusCode, getBodyForError(response)));
    }
    Duration maxAge = extractMaxAge(response);
    return maxAge;
  }
});
origin: airlift/airlift

public ServiceDescriptors(String type,
    String pool,
    List<ServiceDescriptor> serviceDescriptors,
    Duration maxAge,
    String eTag)
{
  requireNonNull(type, "type is null");
  requireNonNull(serviceDescriptors, "serviceDescriptors is null");
  requireNonNull(maxAge, "maxAge is null");
  this.type = type;
  this.pool = pool;
  this.serviceDescriptors = ImmutableList.copyOf(serviceDescriptors);
  this.maxAge = maxAge;
  this.eTag = eTag;
  // verify service descriptors match expected type
  for (ServiceDescriptor serviceDescriptor : this.serviceDescriptors) {
    if (!type.equals(serviceDescriptor.getType()) || (pool != null && !pool.equals(serviceDescriptor.getPool()))) {
      throw new DiscoveryException(format("Expected %s service descriptor from pool %s, but was %s service descriptor from pool %s",
          type,
          pool,
          serviceDescriptor.getType(),
          serviceDescriptor.getPool()));
    }
  }
}
origin: com.teradata.airlift/discovery

public ServiceDescriptors(String type,
    String pool,
    List<ServiceDescriptor> serviceDescriptors,
    Duration maxAge,
    String eTag)
{
  Preconditions.checkNotNull(type, "type is null");
  Preconditions.checkNotNull(serviceDescriptors, "serviceDescriptors is null");
  Preconditions.checkNotNull(maxAge, "maxAge is null");
  this.type = type;
  this.pool = pool;
  this.serviceDescriptors = ImmutableList.copyOf(serviceDescriptors);
  this.maxAge = maxAge;
  this.eTag = eTag;
  // verify service descriptors match expected type
  for (ServiceDescriptor serviceDescriptor : this.serviceDescriptors) {
    if (!type.equals(serviceDescriptor.getType()) || (pool != null && !pool.equals(serviceDescriptor.getPool()))) {
      throw new DiscoveryException(format("Expected %s service descriptor from pool %s, but was %s service descriptor from pool %s",
          type,
          pool,
          serviceDescriptor.getType(),
          serviceDescriptor.getPool()));
    }
  }
}
origin: io.airlift/discovery-experimental

public ServiceDescriptors(String type,
    String pool,
    List<ServiceDescriptor> serviceDescriptors,
    Duration maxAge,
    String eTag)
{
  Preconditions.checkNotNull(type, "type is null");
  Preconditions.checkNotNull(serviceDescriptors, "serviceDescriptors is null");
  Preconditions.checkNotNull(maxAge, "maxAge is null");
  this.type = type;
  this.pool = pool;
  this.serviceDescriptors = ImmutableList.copyOf(serviceDescriptors);
  this.maxAge = maxAge;
  this.eTag = eTag;
  // verify service descriptors match expected type
  for (ServiceDescriptor serviceDescriptor : this.serviceDescriptors) {
    if (!type.equals(serviceDescriptor.getType()) || (pool != null && !pool.equals(serviceDescriptor.getPool()))) {
      throw new DiscoveryException(format("Expected %s service descriptor from pool %s, but was %s service descriptor from pool %s",
          type,
          pool,
          serviceDescriptor.getType(),
          serviceDescriptor.getPool()));
    }
  }
}
origin: airlift/airlift

return immediateFailedFuture(new DiscoveryException("No discovery servers are available"));
    throw new DiscoveryException(format("Lookup of %s failed with status code %s", type, response.getStatusCode()));
    throw new DiscoveryException(format("Lookup of %s failed", type), e);
    throw new DiscoveryException(format("Expected environment to be %s, but was %s", environment, serviceDescriptorsRepresentation.getEnvironment()));
origin: io.airlift/discovery-experimental

return Futures.immediateFailedCheckedFuture(new DiscoveryException("No discovery servers are available"));
    throw new DiscoveryException(format("Lookup of %s failed with status code %s", type, response.getStatusCode()));
    throw new DiscoveryException(format("Lookup of %s failed", type), e);
    throw new DiscoveryException(format("Expected environment to be %s, but was %s", environment, serviceDescriptorsRepresentation.getEnvironment()));
io.airlift.discovery.clientDiscoveryException

Most used methods

  • <init>
  • getCause
  • getMessage

Popular in Java

  • Parsing JSON documents to java classes using gson
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Notification (javax.management)
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now