Tabnine Logo
ConsulException.getCode
Code IndexAdd Tabnine to your IDE (free)

How to use
getCode
method
in
com.orbitz.consul.ConsulException

Best Java code snippets using com.orbitz.consul.ConsulException.getCode (Showing top 4 results out of 315)

origin: couchbase/couchbase-elasticsearch-connector

public static List<String> listKeys(KeyValueClient kv, String keyPrefix) {
 try {
  return kv.getKeys(keyPrefix);
 } catch (ConsulException e) {
  if (e.getCode() == HTTP_NOT_FOUND) {
   return new ArrayList<>(0);
  }
  throw e;
 }
}
origin: rickfast/consul-client

/**
 * Retrieves a {@link com.orbitz.consul.model.kv.Value} for a specific key
 * from the key/value store.
 *
 * GET /v1/kv/{key}
 *
 * @param key The key to retrieve.
 * @param queryOptions The query options.
 * @return An {@link Optional} containing the value or {@link Optional#empty()()}
 */
public Optional<Value> getValue(String key, QueryOptions queryOptions) {
  try {
    return getSingleValue(http.extract(api.getValue(trimLeadingSlash(key), queryOptions.toQuery()), NOT_FOUND_404));
  } catch (ConsulException ignored) {
    if(ignored.getCode() != NOT_FOUND_404) {
      throw ignored;
    }
  }
  return Optional.empty();
}
origin: rickfast/consul-client

/**
 * Returns a {@link ConsulResponse<Value>} for a specific key from the kv store.
 * Contains the consul response headers along with the configuration value.
 *
 * GET /v1/kv/{key}
 *
 * @param key The key to retrieve.
 * @param queryOptions The query options.
 * @return An {@link Optional} containing the ConsulResponse or {@link Optional#empty()}
 */
public Optional<ConsulResponse<Value>> getConsulResponseWithValue(String key, QueryOptions queryOptions) {
  try {
    ConsulResponse<List<Value>> consulResponse =
        http.extractConsulResponse(api.getValue(trimLeadingSlash(key), queryOptions.toQuery()), NOT_FOUND_404);
    Optional<Value> consulValue = getSingleValue(consulResponse.getResponse());
    if (consulValue.isPresent()) {
      ConsulResponse<Value> result =
          new ConsulResponse<>(consulValue.get(), consulResponse.getLastContact(),
                        consulResponse.isKnownLeader(), consulResponse.getIndex());
      return Optional.of(result);
    }
  } catch (ConsulException ignored) {
    if (ignored.getCode() != NOT_FOUND_404) {
      throw ignored;
    }
  }
  return Optional.empty();
}
origin: couchbase/couchbase-elasticsearch-connector

/**
 * Returns {@code true} if the given session owned the lock, otherwise {@code false}.
 */
public static boolean unlockAndDelete(KeyValueClient kv, String key, String sessionId) {
 try {
  kv.performTransaction(
    ImmutableOperation.builder(Verb.UNLOCK).key(key).session(sessionId).build(),
    ImmutableOperation.builder(Verb.DELETE).key(key).build());
  return true;
 } catch (ConsulException e) {
  if (e.getCode() == HTTP_CONFLICT) {
   return false; // didn't own lock; no worries
  }
  throw e;
 }
}
com.orbitz.consulConsulExceptiongetCode

Popular methods of ConsulException

  • <init>
  • message

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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