Package com.apple.foundationdb
Class LocalityUtil
- java.lang.Object
-
- com.apple.foundationdb.LocalityUtil
-
public class LocalityUtil extends java.lang.Object
The FoundationDB API comes with a set of functions for discovering the storage locations of keys within your cluster. This information can be useful for advanced users who wish to take into account the location of keys in the design of applications or processes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.CompletableFuture<java.lang.String[]>
getAddressesForKey(Transaction tr, byte[] key)
Returns a list of public network addresses as strings, one for each of the storage servers responsible for storingkey
and its associated value.static CloseableAsyncIterator<byte[]>
getBoundaryKeys(Database db, byte[] begin, byte[] end)
Returns aCloseableAsyncIterator
of keysk
such thatbegin <= k < end
andk
is located at the start of a contiguous range stored on a single server.
This method is not transactional.static CloseableAsyncIterator<byte[]>
getBoundaryKeys(Transaction tr, byte[] begin, byte[] end)
Returns aCloseableAsyncIterator
of keysk
such thatbegin <= k < end
andk
is located at the start of a contiguous range stored on a single server.
This method is not transactional.
-
-
-
Method Detail
-
getBoundaryKeys
public static CloseableAsyncIterator<byte[]> getBoundaryKeys(Database db, byte[] begin, byte[] end)
Returns aCloseableAsyncIterator
of keysk
such thatbegin <= k < end
andk
is located at the start of a contiguous range stored on a single server.
This method is not transactional. The returned boundaries are an estimate and may not represent the exact boundary locations at any database version.- Parameters:
db
- the database to querybegin
- the inclusive start of the rangeend
- the exclusive end of the range- Returns:
- an sequence of keys denoting the start of single-server ranges
-
getBoundaryKeys
public static CloseableAsyncIterator<byte[]> getBoundaryKeys(Transaction tr, byte[] begin, byte[] end)
Returns aCloseableAsyncIterator
of keysk
such thatbegin <= k < end
andk
is located at the start of a contiguous range stored on a single server.
This method is not transactional. The returned boundaries are an estimate and may not represent the exact boundary locations at any database version. The passedTransaction
is not used for reads directly, instead it is used to get access to associatedDatabase
. As a result, options (such as retry limit) set on the passedTransaction
will not be applied. If, however, the passedTransaction
has already gotten a read version there is some latency advantage to using this form of the method. Also, if the database is unavailable prior to the function call, any timeout set on the passedTransaction
will still trigger.- Parameters:
tr
- the transaction on which to base the querybegin
- the inclusive start of the rangeend
- the exclusive end of the range- Returns:
- an sequence of keys denoting the start of single-server ranges
-
getAddressesForKey
public static java.util.concurrent.CompletableFuture<java.lang.String[]> getAddressesForKey(Transaction tr, byte[] key)
Returns a list of public network addresses as strings, one for each of the storage servers responsible for storingkey
and its associated value. If locality information is not available, the returned future will carry aFDBException
locality_information_unavailable.- Parameters:
tr
- the transaction in which to gather location informationkey
- the key for which to gather location information- Returns:
- a list of addresses in string form
-
-