RangeShardMapper Class
- java.
lang. Object - BaseShardMapper
- com.
microsoft. azure. elasticdb. shard. mapper. RangeShardMapper
- com.
public class RangeShardMapper extends BaseShardMapper implements IShardMapper<RangeMapping, Object>
Mapper from a range of keys to their corresponding shards.
Constructor Summary
Constructor | Description |
---|---|
RangeShardMapper(ShardMapManager shardMapManager, ShardMap sm) |
Range shard mapper, which managers range mappings. |
Method Summary
Modifier and Type | Method and Description |
---|---|
final Range |
add(RangeMapping mapping)
Adds a range mapping. |
final UUID |
getLockOwnerForMapping(RangeMapping mapping)
Gets the lock owner of a mapping. |
final List<Range |
getMappingsForRange(Range range, Shard shard, LookupOptions lookupOptions)
Gets all the mappings that exist within given range. |
final void |
lockOrUnlockMappings(RangeMapping mapping, UUID lockOwnerId, LockOwnerIdOpType lockOwnerIdOpType)
Locks or unlocks a given mapping or all mappings. |
final Range |
lookup(Object key, LookupOptions lookupOptions)
Looks up the key value and returns the corresponding mapping. |
final Range |
markMappingOffline(RangeMapping mapping, UUID lockOwnerId)
Marks the given mapping offline. |
final Range |
markMappingOnline(RangeMapping mapping, UUID lockOwnerId)
Marks the given mapping online. |
final Range |
merge(RangeMapping left, RangeMapping right, UUID leftLockOwnerId, UUID rightLockOwnerId)
Merges 2 contiguous mappings into a single mapping. Both left and right mappings should point to the same location and must be contiguous. |
final Connection | openConnectionForKey(Object key, String connectionString) |
final Connection |
openConnectionForKey(Object key, String connectionString, ConnectionOptions options)
Given a key value, obtains a SqlConnection to the shard in the mapping that contains the key value. |
final Callable<Connection> | openConnectionForKeyAsync(Object key, String connectionString) |
final Callable<Connection> |
openConnectionForKeyAsync(Object key, String connectionString, ConnectionOptions options)
Given a key value, asynchronously obtains a SqlConnection to the shard in the mapping that contains the key value. |
final void |
remove(RangeMapping mapping, UUID lockOwnerId)
Removes a range mapping. |
final List<Range |
split(RangeMapping existingMapping, Object splitAt, UUID lockOwnerId)
Splits the given mapping into 2 at the given key. The new mappings point to the same shard as the existing mapping. |
final boolean |
tryLookup(Object key, LookupOptions lookupOptions, ReferenceObjectHelper<RangeMapping> mapping)
Tries to looks up the key value and returns the corresponding mapping. |
final Range |
update(RangeMapping currentMapping, RangeMappingUpdate update, UUID lockOwnerId)
Allows for update to a range mapping with the updates provided in the update parameter. |
Inherited Members
Constructor Details
RangeShardMapper
public RangeShardMapper(ShardMapManager shardMapManager, ShardMap sm)
Range shard mapper, which managers range mappings.
Parameters:
Method Details
add
public final RangeMapping add(RangeMapping mapping)
Adds a range mapping.
Parameters:
Returns:
getLockOwnerForMapping
public final UUID getLockOwnerForMapping(RangeMapping mapping)
Gets the lock owner of a mapping.
Parameters:
Returns:
getMappingsForRange
public final List
Gets all the mappings that exist within given range.
Parameters:
Returns:
lockOrUnlockMappings
public final void lockOrUnlockMappings(RangeMapping mapping, UUID lockOwnerId, LockOwnerIdOpType lockOwnerIdOpType)
Locks or unlocks a given mapping or all mappings.
Parameters:
lookup
public final RangeMapping lookup(Object key, LookupOptions lookupOptions)
Looks up the key value and returns the corresponding mapping.
Parameters:
Returns:
markMappingOffline
public final RangeMapping markMappingOffline(RangeMapping mapping, UUID lockOwnerId)
Marks the given mapping offline.
Parameters:
Returns:
markMappingOnline
public final RangeMapping markMappingOnline(RangeMapping mapping, UUID lockOwnerId)
Marks the given mapping online.
Parameters:
Returns:
merge
public final RangeMapping merge(RangeMapping left, RangeMapping right, UUID leftLockOwnerId, UUID rightLockOwnerId)
Merges 2 contiguous mappings into a single mapping. Both left and right mappings should point to the same location and must be contiguous.
Parameters:
Returns:
openConnectionForKey
public final Connection openConnectionForKey(Object key, String connectionString)
Parameters:
openConnectionForKey
public final Connection openConnectionForKey(Object key, String connectionString, ConnectionOptions options)
Given a key value, obtains a SqlConnection to the shard in the mapping that contains the key value.
Parameters:
Returns:
openConnectionForKeyAsync
public final Callable
Parameters:
openConnectionForKeyAsync
public final Callable
Given a key value, asynchronously obtains a SqlConnection to the shard in the mapping that contains the key value.
Parameters:
Returns:
remove
public final void remove(RangeMapping mapping, UUID lockOwnerId)
Removes a range mapping.
Parameters:
split
public final List
Splits the given mapping into 2 at the given key. The new mappings point to the same shard as the existing mapping.
Parameters:
Returns:
tryLookup
public final boolean tryLookup(Object key, LookupOptions lookupOptions, ReferenceObjectHelper
Tries to looks up the key value and returns the corresponding mapping.
Parameters:
Returns:
true
if mapping is found, false
otherwise.
update
public final RangeMapping update(RangeMapping currentMapping, RangeMappingUpdate update, UUID lockOwnerId)
Allows for update to a range mapping with the updates provided in the update parameter.
Parameters:
Returns:
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for