Tabnine Logo
DistributedMap
Code IndexAdd Tabnine to your IDE (free)

How to use
DistributedMap
in
com.oath.micro.server.distributed

Best Java code snippets using com.oath.micro.server.distributed.DistributedMap (Showing top 16 results out of 315)

origin: aol/micro-server

private VersionedKey loadKeyFromCouchbase() {
  Optional<String> optionalKey = connection.get(key);
  return optionalKey.flatMap(val -> Optional.of(JacksonUtil.convertFromJson(val, VersionedKey.class)))
           .orElse(newKey(0L));
}
origin: aol/micro-server

  @GET
  @Path("/put")
  public String put() {
    client.put("hello", "world");
    return "added";
  }
}
origin: aol/micro-server

private void delete(String withVersion) {
  connection.delete(withVersion);
}
origin: aol/micro-server

@SuppressWarnings("unchecked")
private Object nonAtomicload(String newVersionedKey) throws Throwable {
  Data data = (Data) connection.get(newVersionedKey)
                 .orElseThrow(() -> {
                   return new ManifestComparatorKeyNotFoundException(
                                            "Missing versioned key "
                                                + newVersionedKey
                                                + " - likely data changed during read");
                 });
  logger.info("Loaded new data with date {} for key {}, versionedKey {}, versionedKey from data ",
        new Object[] { data.getDate(), key, newVersionedKey, data.getVersionedKey() });
  return data.getData();
}
origin: aol/micro-server

  @GET
  @Path("/put")
  public String put() {
    client.put("hello", "world");
    return "added";
  }
}
origin: aol/micro-server

@GET
@Path("/get")
public String bucket() {
  return client.get("hello")
         .toString();
}
origin: aol/micro-server

  @GET
  @Path("/put")
  public String put() {
    client.put("hello", "world");
    return "added";
  }
}
origin: aol/micro-server

@GET
@Path("/get")
public String bucket() {
  return client.get("hello")
         .toString();
}
origin: aol/micro-server

  @GET
  @Path("/put")
  public String put() {
    client.put("hello", "world");
    return "added";
  }
}
origin: aol/micro-server

@GET
@Path("/get")
public String bucket() {
  return client.get("hello").toString();
}
origin: aol/micro-server

  @GET
  @Path("/put")
  public String put() {
    client.put("hello", "world");
    return "added";
  }
}
origin: aol/micro-server

@GET
@Path("/get")
public String bucket() {
  return client.get("hello").toString();
}
origin: aol/micro-server

/**
 * Save provided data with the key this ManifestComparator manages bump the
 * versioned key version.
 * 
 * NB : To avoid race conditions - make sure only one service (an elected
 * leader) can write at a time (see micro-mysql for a mysql distributed
 * lock, or micro-curator for a curator / zookeeper distributed lock
 * implementation).
 * 
 * @param data
 *            to save
 */
@Override
public void saveAndIncrement(T data) {
  Either<Void, T> oldData = this.data;
  VersionedKey newVersionedKey = increment();
  logger.info("Saving data with key {}, new version is {}", key, newVersionedKey.toJson());
  connection.put(newVersionedKey.toJson(), new Data(
                           data, new Date(), newVersionedKey.toJson()));
  connection.put(key, newVersionedKey.toJson());
  try {
    this.data = Either.right(data);
    delete(versionedKey);
  } catch (Throwable t) {
    this.data = oldData;
  } finally {
    versionedKey = newVersionedKey.toJson();
  }
}
origin: aol/micro-server

@GET
@Path("/get")
public String bucket() {
  return client.get("hello")
         .toString();
}
origin: aol/micro-server

/**
 * Load data from remote store if stale
 */
@Override
public synchronized boolean load() {
  Either<Void, T> oldData = data;
  String oldKey = versionedKey;
  try {
    if (isOutOfDate()) {
      String newVersionedKey = (String) connection.get(key)
                            .get();
      data = Either.right((T) nonAtomicload(newVersionedKey));
      versionedKey = newVersionedKey;
    } else {
      return false;
    }
  } catch (Throwable e) {
    data = oldData;
    versionedKey = oldKey;
    logger.debug(e.getMessage(), e);
    throw ExceptionSoftener.throwSoftenedException(e);
  }
  return true;
}
origin: aol/micro-server

@Test
public void createDistributedCacheMemcachedOff() throws IOException, URISyntaxException {
  config.setCouchbaseClientEnabled(false);
  DistributedMap<Object> cache = config.simpleCouchbaseClient();
  assertThat(cache.get("hello"), is(Optional.empty()));
}
com.oath.micro.server.distributedDistributedMap

Most used methods

  • get
  • put
  • delete

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
  • onCreateOptionsMenu (Activity)
  • Menu (java.awt)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Path (java.nio.file)
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • 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