Delen via


RangeShardMap<KeyT> Class

  • java.lang.Object
    • Cloneable
      • ShardMap
        • com.microsoft.azure.elasticdb.shard.map.RangeShardMap<KeyT>

Type Parameters

KeyT

public class RangeShardMap extends ShardMap

Represents a shard map of ranges. .

Constructor Summary

Constructor Description
RangeShardMap(ShardMapManager shardMapManager, StoreShardMap ssm)

Constructs a new instance.

Method Summary

Modifier and Type Method and Description
RangeShardMap<KeyT> clone()

Clones the given range shard map.

ShardMap cloneCore()

Clones the current shard map instance.

RangeMapping createRangeMapping(Range range, Shard shard)

Creates and adds a range mapping to ShardMap.

RangeMapping createRangeMapping(RangeMappingCreationInfo creationInfo)

Creates and adds a range mapping to ShardMap.

void deleteMapping(RangeMapping mapping)

Removes a range mapping.

void deleteMapping(RangeMapping mapping, MappingLockToken mappingLockToken)

Removes a range mapping.

<V> IShardMapper getMapper()

Gets the mapper. This method is used by OpenConnection/Lookup of V.

RangeMapping getMappingForKey(KeyT key)

Looks up the key value and returns the corresponding mapping.

RangeMapping getMappingForKey(KeyT key, LookupOptions lookupOptions)

Looks up the key value and returns the corresponding mapping.

MappingLockToken getMappingLockOwner(RangeMapping mapping)

Gets the lock owner id of the specified mapping.

List<RangeMapping> getMappings()

Gets all the range mappings for the shard map.

List<RangeMapping> getMappings(LookupOptions lookupOptions)

Gets all the range mappings for the shard map.

List<RangeMapping> getMappings(Range range)

Gets all the range mappings that exist within given range.

List<RangeMapping> getMappings(Range range, LookupOptions lookupOptions)

Gets all the range mappings that exist within given range.

List<RangeMapping> getMappings(Range range, Shard shard)

Gets all the range mappings that exist within given range and given shard.

List<RangeMapping> getMappings(Range range, Shard shard, LookupOptions lookupOptions)

Gets all the range mappings that exist within given range and given shard.

List<RangeMapping> getMappings(Shard shard)

Gets all the range mappings that exist for the given shard.

List<RangeMapping> getMappings(Shard shard, LookupOptions lookupOptions)

Gets all the range mappings that exist for the given shard.

void lockMapping(RangeMapping mapping, MappingLockToken mappingLockToken)

Locks the mapping for the specified owner The state of a locked mapping can only be modified by the lock owner.

RangeMapping markMappingOffline(RangeMapping mapping)

Marks the specified mapping offline.

RangeMapping markMappingOffline(RangeMapping mapping, MappingLockToken mappingLockToken)

Marks the specified mapping offline.

RangeMapping markMappingOnline(RangeMapping mapping)

Marks the specified mapping online.

RangeMapping markMappingOnline(RangeMapping mapping, MappingLockToken mappingLockToken)

Marks the specified mapping online.

RangeMapping mergeMappings(RangeMapping left, RangeMapping right)

Merges 2 contiguous mappings into a single mapping. Both left and right mappings should point to the same location and must be contiguous.

RangeMapping mergeMappings(RangeMapping left, RangeMapping right, MappingLockToken leftMappingLockToken, MappingLockToken rightMappingLockToken)

Merges 2 contiguous mappings into a single mapping. Both left and right mappings should point to the same location and must be contiguous.

List<RangeMapping> splitMapping(RangeMapping existingMapping, KeyT splitAt)

Splits the specified mapping into two new mappings using the specified key as boundary. The new mappings point to the same shard as the existing mapping.

List<RangeMapping> splitMapping(RangeMapping existingMapping, KeyT splitAt, MappingLockToken mappingLockToken)

Splits the specified mapping into two new mappings using the specified key as boundary. The new mappings point to the same shard as the existing mapping.

boolean tryGetMappingForKey(KeyT key, LookupOptions lookupOptions, ReferenceObjectHelper<RangeMapping> rangeMapping)

Tries to looks up the key value and place the corresponding mapping in rangeMapping .

boolean tryGetMappingForKey(KeyT key, ReferenceObjectHelper<RangeMapping> rangeMapping)

Tries to looks up the key value and place the corresponding mapping in rangeMapping .

void unlockMapping(MappingLockToken mappingLockToken)

Unlocks all mappings in this map that belong to the given MappingLockToken.

void unlockMapping(RangeMapping mapping, MappingLockToken mappingLockToken)

Unlocks the specified mapping

RangeMapping updateMapping(RangeMapping currentMapping, RangeMappingUpdate update)

Updates a RangeMapping<KeyT> with the updates provided in the update parameter.

RangeMapping updateMapping(RangeMapping currentMapping, RangeMappingUpdate update, MappingLockToken mappingLockToken)

Updates a RangeMapping<KeyT> with the updates provided in the update parameter.

Inherited Members

Constructor Details

RangeShardMap

public RangeShardMap(ShardMapManager shardMapManager, StoreShardMap ssm)

Constructs a new instance.

Parameters:

shardMapManager - Reference to ShardMapManager.
ssm - Storage representation.

Method Details

clone

public RangeShardMap clone()

Clones the given range shard map.

Returns:

A cloned instance of the range shard map.

cloneCore

protected ShardMap cloneCore()

Clones the current shard map instance.

Returns:

Cloned shard map instance.

createRangeMapping

public RangeMapping createRangeMapping(Range range, Shard shard)

Creates and adds a range mapping to ShardMap.

Parameters:

range - Range for which to create the mapping.
shard - Shard associated with the range mapping.

Returns:

Newly created mapping.

createRangeMapping

public RangeMapping createRangeMapping(RangeMappingCreationInfo creationInfo)

Creates and adds a range mapping to ShardMap.

Parameters:

creationInfo - Information about mapping to be added.

Returns:

Newly created mapping.

deleteMapping

public void deleteMapping(RangeMapping mapping)

Removes a range mapping.

Parameters:

mapping - Mapping being removed.

deleteMapping

public void deleteMapping(RangeMapping mapping, MappingLockToken mappingLockToken)

Removes a range mapping.

Parameters:

mapping - Mapping being removed.
mappingLockToken - An instance of MappingLockToken

getMapper

public IShardMapper getMapper()

Gets the mapper. This method is used by OpenConnection/Lookup of V.

Returns:

RangeShardMapper for given key type.

getMappingForKey

public RangeMapping getMappingForKey(KeyT key)

Looks up the key value and returns the corresponding mapping.

Parameters:

key - Input key value.

Returns:

Mapping that contains the key value.

getMappingForKey

public RangeMapping getMappingForKey(KeyT key, LookupOptions lookupOptions)

Looks up the key value and returns the corresponding mapping.

Parameters:

key - Input key value.
lookupOptions - Whether to search in the cache and/or store.

Returns:

Mapping that contains the key value.

getMappingLockOwner

public MappingLockToken getMappingLockOwner(RangeMapping mapping)

Gets the lock owner id of the specified mapping.

Parameters:

mapping - Input range mapping.

Returns:

An instance of MappingLockToken

getMappings

public List getMappings()

Gets all the range mappings for the shard map.

Returns:

Read-only collection of all range mappings on the shard map.

getMappings

public List getMappings(LookupOptions lookupOptions)

Gets all the range mappings for the shard map.

Parameters:

lookupOptions - Whether to search in the cache and/or store.

Returns:

Read-only collection of all range mappings on the shard map.

getMappings

public List getMappings(Range range)

Gets all the range mappings that exist within given range.

Parameters:

range - Range value, any mapping overlapping with the range will be returned.

Returns:

Read-only collection of mappings that satisfy the given range constraint.

getMappings

public List getMappings(Range range, LookupOptions lookupOptions)

Gets all the range mappings that exist within given range.

Parameters:

range - Range value, any mapping overlapping with the range will be returned.
lookupOptions - Whether to search in the cache and/or store.

Returns:

Read-only collection of mappings that satisfy the given range constraint.

getMappings

public List getMappings(Range range, Shard shard)

Gets all the range mappings that exist within given range and given shard.

Parameters:

range - Range value, any mapping overlapping with the range will be returned.
shard - Shard for which the mappings will be returned.

Returns:

Read-only collection of mappings that satisfy the given range and shard constraints.

getMappings

public List getMappings(Range range, Shard shard, LookupOptions lookupOptions)

Gets all the range mappings that exist within given range and given shard.

Parameters:

range - Range value, any mapping overlapping with the range will be returned.
shard - Shard for which the mappings will be returned.
lookupOptions - Whether to search in the cache and/or store.

Returns:

Read-only collection of mappings that satisfy the given range and shard constraints.

getMappings

public List getMappings(Shard shard)

Gets all the range mappings that exist for the given shard.

Parameters:

shard - Shard for which the mappings will be returned.

Returns:

Read-only collection of mappings that satisfy the given shard constraint.

getMappings

public List getMappings(Shard shard, LookupOptions lookupOptions)

Gets all the range mappings that exist for the given shard.

Parameters:

shard - Shard for which the mappings will be returned.
lookupOptions - Whether to search in the cache and/or store.

Returns:

Read-only collection of mappings that satisfy the given shard constraint.

lockMapping

public void lockMapping(RangeMapping mapping, MappingLockToken mappingLockToken)

Locks the mapping for the specified owner The state of a locked mapping can only be modified by the lock owner.

Parameters:

mapping - Input range mapping.
mappingLockToken - An instance of MappingLockToken

markMappingOffline

public RangeMapping markMappingOffline(RangeMapping mapping)

Marks the specified mapping offline.

Parameters:

mapping - Input range mapping.

Returns:

An offline mapping.

markMappingOffline

public RangeMapping markMappingOffline(RangeMapping mapping, MappingLockToken mappingLockToken)

Marks the specified mapping offline.

Parameters:

mapping - Input range mapping.
mappingLockToken - An instance of MappingLockToken

Returns:

An offline mapping.

markMappingOnline

public RangeMapping markMappingOnline(RangeMapping mapping)

Marks the specified mapping online.

Parameters:

mapping - Input range mapping.

Returns:

An online mapping.

markMappingOnline

public RangeMapping markMappingOnline(RangeMapping mapping, MappingLockToken mappingLockToken)

Marks the specified mapping online.

Parameters:

mapping - Input range mapping.
mappingLockToken - An instance of MappingLockToken

Returns:

An online mapping.

mergeMappings

public RangeMapping mergeMappings(RangeMapping left, RangeMapping right)

Merges 2 contiguous mappings into a single mapping. Both left and right mappings should point to the same location and must be contiguous.

Parameters:

left - Left mapping.
right - Right mapping.

Returns:

Mapping that results from the merge operation.

mergeMappings

public RangeMapping mergeMappings(RangeMapping left, RangeMapping right, MappingLockToken leftMappingLockToken, MappingLockToken rightMappingLockToken)

Merges 2 contiguous mappings into a single mapping. Both left and right mappings should point to the same location and must be contiguous.

Parameters:

left - Left mapping.
right - Right mapping.
leftMappingLockToken - An instance of MappingLockToken for the left mapping
rightMappingLockToken - An instance of MappingLockToken for the right mapping

Returns:

Mapping that results from the merge operation.

splitMapping

public List splitMapping(RangeMapping existingMapping, KeyT splitAt)

Splits the specified mapping into two new mappings using the specified key as boundary. The new mappings point to the same shard as the existing mapping.

Parameters:

existingMapping - Existing mapping.
splitAt - Split point.

Returns:

Read-only collection of two new mappings that were created.

splitMapping

public List splitMapping(RangeMapping existingMapping, KeyT splitAt, MappingLockToken mappingLockToken)

Splits the specified mapping into two new mappings using the specified key as boundary. The new mappings point to the same shard as the existing mapping.

Parameters:

existingMapping - Existing mapping.
splitAt - Split point.
mappingLockToken - An instance of MappingLockToken

Returns:

Read-only collection of two new mappings that were created.

tryGetMappingForKey

public boolean tryGetMappingForKey(KeyT key, LookupOptions lookupOptions, ReferenceObjectHelper rangeMapping)

Tries to looks up the key value and place the corresponding mapping in rangeMapping .

Parameters:

key - Input key value.
lookupOptions - Whether to search in the cache and/or store.
rangeMapping - Mapping that contains the key value.

Returns:

true if mapping is found, false otherwise.

tryGetMappingForKey

public boolean tryGetMappingForKey(KeyT key, ReferenceObjectHelper rangeMapping)

Tries to looks up the key value and place the corresponding mapping in rangeMapping .

Parameters:

key - Input key value.
rangeMapping - Mapping that contains the key value.

Returns:

true if mapping is found, false otherwise.

unlockMapping

public void unlockMapping(MappingLockToken mappingLockToken)

Unlocks all mappings in this map that belong to the given MappingLockToken.

Parameters:

mappingLockToken - An instance of MappingLockToken

unlockMapping

public void unlockMapping(RangeMapping mapping, MappingLockToken mappingLockToken)

Unlocks the specified mapping

Parameters:

mapping - Input range mapping.
mappingLockToken - An instance of MappingLockToken

updateMapping

public RangeMapping updateMapping(RangeMapping currentMapping, RangeMappingUpdate update)

Updates a RangeMapping<KeyT> with the updates provided in the update parameter.

Parameters:

currentMapping - Mapping being updated.
update - Updated properties of the mapping.

Returns:

New instance of mapping with updated information.

updateMapping

public RangeMapping updateMapping(RangeMapping currentMapping, RangeMappingUpdate update, MappingLockToken mappingLockToken)

Updates a RangeMapping<KeyT> with the updates provided in the update parameter.

Parameters:

currentMapping - Mapping being updated.
update - Updated properties of the mapping.
mappingLockToken - An instance of MappingLockToken

Returns:

New instance of mapping with updated information.

Applies to