/** * {@inheritDoc} */ @Override public void deleteAll(List<K> keys) { try { deleteAllAsync(keys).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAsync(K key, V value) { Preconditions.checkNotNull(key); if (value == null) { return deleteAsync(key); } writeMetrics.numPuts.inc(); return execute(writeRateLimiter, key, value, writeFn::putAsync, writeMetrics.putNs) .exceptionally(e -> { throw new SamzaException("Failed to put a record with key=" + key, (Throwable) e); }); }
/** * {@inheritDoc} */ @Override public void putAll(List<Entry<K, V>> entries) { try { putAllAsync(entries).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> deleteAsync(K key) { Preconditions.checkNotNull(key); writeMetrics.numDeletes.inc(); return execute(writeRateLimiter, key, writeFn::deleteAsync, writeMetrics.deleteNs) .exceptionally(e -> { throw new SamzaException(String.format("Failed to delete the record for " + key), (Throwable) e); }); }
/** * {@inheritDoc} */ @Override public void put(K key, V value) { try { putAsync(key, value).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public void delete(K key) { try { deleteAsync(key).get(); } catch (Exception e) { throw new SamzaException(e); } }
tableExecutors.get(tableId), callbackExecutors.get(tableId)); } else { table = new RemoteReadWriteTable(tableSpec.getId(), readFn, writeFn, readRateLimiter, writeRateLimiter, tableExecutors.get(tableId), callbackExecutors.get(tableId));
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> deleteAsync(K key) { Preconditions.checkNotNull(key); writeMetrics.numDeletes.inc(); return execute(writeRateLimiter, key, writeFn::deleteAsync, writeMetrics.deleteNs) .exceptionally(e -> { throw new SamzaException(String.format("Failed to delete the record for " + key), (Throwable) e); }); }
/** * {@inheritDoc} */ @Override public void put(K key, V value) { try { putAsync(key, value).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public void delete(K key) { try { deleteAsync(key).get(); } catch (Exception e) { throw new SamzaException(e); } }
tableExecutors.get(tableId), callbackExecutors.get(tableId)); } else { table = new RemoteReadWriteTable(tableSpec.getId(), readFn, writeFn, readRateLimiter, writeRateLimiter, tableExecutors.get(tableId), callbackExecutors.get(tableId));
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAsync(K key, V value) { Preconditions.checkNotNull(key); if (value == null) { return deleteAsync(key); } writeMetrics.numPuts.inc(); return execute(writeRateLimiter, key, value, writeFn::putAsync, writeMetrics.putNs) .exceptionally(e -> { throw new SamzaException("Failed to put a record with key=" + key, (Throwable) e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> putAllAsync(List<Entry<K, V>> records) { Preconditions.checkNotNull(records); if (records.isEmpty()) { return CompletableFuture.completedFuture(null); } writeMetrics.numPutAlls.inc(); List<K> deleteKeys = records.stream() .filter(e -> e.getValue() == null).map(Entry::getKey).collect(Collectors.toList()); CompletableFuture<Void> deleteFuture = deleteKeys.isEmpty() ? CompletableFuture.completedFuture(null) : deleteAllAsync(deleteKeys); List<Entry<K, V>> putRecords = records.stream() .filter(e -> e.getValue() != null).collect(Collectors.toList()); // Return the combined future return CompletableFuture.allOf( deleteFuture, executeRecords(writeRateLimiter, putRecords, writeFn::putAllAsync, writeMetrics.putAllNs)) .exceptionally(e -> { String strKeys = records.stream().map(r -> r.getKey().toString()).collect(Collectors.joining(",")); throw new SamzaException(String.format("Failed to put records with keys=" + strKeys), e); }); }
/** * {@inheritDoc} */ @Override public CompletableFuture<Void> deleteAsync(K key) { Preconditions.checkNotNull(key); writeMetrics.numDeletes.inc(); return execute(writeRateLimiter, key, writeFn::deleteAsync, writeMetrics.deleteNs) .exceptionally(e -> { throw new SamzaException(String.format("Failed to delete the record for " + key), (Throwable) e); }); }
/** * {@inheritDoc} */ @Override public void put(K key, V value) { try { putAsync(key, value).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public void deleteAll(List<K> keys) { try { deleteAllAsync(keys).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public void putAll(List<Entry<K, V>> entries) { try { putAllAsync(entries).get(); } catch (Exception e) { throw new SamzaException(e); } }
/** * {@inheritDoc} */ @Override public void delete(K key) { try { deleteAsync(key).get(); } catch (Exception e) { throw new SamzaException(e); } }