共用方式為


ListShardMapper Class

  • java.lang.Object
    • BaseShardMapper
      • com.microsoft.azure.elasticdb.shard.mapper.ListShardMapper

public class ListShardMapper extends BaseShardMapper implements IShardMapper<PointMapping, Object>

Mapper from single keys (points) to their corresponding shards.

Constructor Summary

Constructor Description
ListShardMapper(ShardMapManager shardMapManager, ShardMap sm)

List shard mapper, which managers point mappings.

Method Summary

Modifier and Type Method and Description
PointMapping add(PointMapping mapping)

Adds a point mapping.

UUID getLockOwnerForMapping(PointMapping mapping)

Gets the lock owner of a mapping.

List<PointMapping> getMappingsForRange(Range range, Shard shard, LookupOptions lookupOptions)

Gets all the mappings that exist within given range.

void lockOrUnlockMappings(PointMapping mapping, UUID lockOwnerId, LockOwnerIdOpType lockOwnerIdOpType)

Locks or unlocks a given mapping or all mappings.

PointMapping lookup(Object key, LookupOptions lookupOptions)

Looks up the key value and returns the corresponding mapping.

PointMapping markMappingOffline(PointMapping mapping)

Marks the given mapping offline.

PointMapping markMappingOffline(PointMapping mapping, UUID lockOwnerId)

Marks the given mapping offline.

PointMapping markMappingOnline(PointMapping mapping)

Marks the given mapping online.

PointMapping markMappingOnline(PointMapping mapping, UUID lockOwnerId)

Marks the given mapping online.

Connection openConnectionForKey(Object key, String connectionString)

Given a key value, obtains a SqlConnection to the shard in the mapping that contains the key value.

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.

Callable<Connection> openConnectionForKeyAsync(Object key, String connectionString)

Given a key value, asynchronously obtains a SqlConnection to the shard in the mapping that contains the key value.

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.

void remove(PointMapping mapping)

Removes a point mapping.

void remove(PointMapping mapping, UUID lockOwnerId)

Removes a point mapping.

boolean tryLookup(Object key, LookupOptions lookupOptions, ReferenceObjectHelper<PointMapping> mapping)

Tries to looks up the key value and returns the corresponding mapping.

PointMapping update(PointMapping currentMapping, PointMappingUpdate update)

Allows for update to a point mapping with the updates provided in the update parameter.

PointMapping update(PointMapping currentMapping, PointMappingUpdate update, UUID lockOwnerId)

Allows for update to a point mapping with the updates provided in the update parameter.

Inherited Members

BaseShardMapper.add(MappingT mapping, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping) IShardMapper<MappingT,ValueT>.add(MappingT mapping) BaseShardMapper.BaseShardMapper(ShardMapManager shardMapManager, ShardMap sm) BaseShardMapper.DEFAULT_OWNER BaseShardMapper.ensureMappingBelongsToShardMap(MappingT mapping, String operationName, String parameterName) BaseShardMapper.getLockOwnerForMapping(MappingT mapping, ShardManagementErrorCategory errorCategory) BaseShardMapper.getMappingsForRange(Range range, Shard shard, LookupOptions lookupOptions, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, ShardManagementErrorCategory errorCategory, String mappingType) BaseShardMapper.getShardMap() BaseShardMapper.getShardMapManager() BaseShardMapper.lockOrUnlockMappings(MappingT mapping, UUID lockOwnerId, LockOwnerIdOpType lockOwnerIdOpType, ShardManagementErrorCategory errorCategory) BaseShardMapper.lookup(KeyT key, LookupOptions lookupOptions, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, ShardManagementErrorCategory errorCategory) IShardMapper<MappingT,ValueT>.lookup(ValueT key, LookupOptions lookupOptions) BaseShardMapper.openConnectionForKey(KeyT key, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, ShardManagementErrorCategory errorCategory, String connectionString) BaseShardMapper.openConnectionForKey(KeyT key, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, ShardManagementErrorCategory errorCategory, String connectionString, ConnectionOptions options) IShardMapper<MappingT,ValueT>.openConnectionForKey(ValueT key, String connectionString) IShardMapper<MappingT,ValueT>.openConnectionForKey(ValueT key, String connectionString, ConnectionOptions options) BaseShardMapper.openConnectionForKeyAsync(KeyT key, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, ShardManagementErrorCategory errorCategory, String connectionString) BaseShardMapper.openConnectionForKeyAsync(KeyT key, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, ShardManagementErrorCategory errorCategory, String connectionString, ConnectionOptions options) IShardMapper<MappingT,ValueT>.openConnectionForKeyAsync(ValueT key, String connectionString) IShardMapper<MappingT,ValueT>.openConnectionForKeyAsync(ValueT key, String connectionString, ConnectionOptions options) BaseShardMapper.remove(MappingT mapping, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, UUID lockOwnerId) IShardMapper<MappingT,ValueT>.remove(MappingT mapping, UUID lockOwnerId) BaseShardMapper.setStatus(MappingT mapping, StatusT status, Function<StatusT, StatusT> getStatus, Function<StatusT, UpdateT> createUpdate, ActionGeneric3Param<MappingT, UpdateT, UUID, MappingT> runUpdate) BaseShardMapper.setStatus(MappingT mapping, StatusT status, Function<StatusT, StatusT> getStatus, Function<StatusT, UpdateT> createUpdate, ActionGeneric3Param<MappingT, UpdateT, UUID, MappingT> runUpdate, UUID lockOwnerId) BaseShardMapper.shardMap BaseShardMapper.shardMapManager IShardMapper<MappingT,ValueT>.tryLookup(ValueT key, LookupOptions lookupOptions, ReferenceObjectHelper<MappingT> mapping) BaseShardMapper.update(MappingT currentMapping, UpdateT update, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, Function<StatusT, Integer> statusAsInt, Function<Integer, StatusT> intAsStatus) BaseShardMapper.update(MappingT currentMapping, UpdateT update, ActionGeneric3Param<ShardMapManager, ShardMap, StoreMapping, MappingT> constructMapping, Function<StatusT, Integer> statusAsInt, Function<Integer, StatusT> intAsStatus, UUID lockOwnerId)

Constructor Details

ListShardMapper

public ListShardMapper(ShardMapManager shardMapManager, ShardMap sm)

List shard mapper, which managers point mappings.

Parameters:

shardMapManager - Reference to ShardMapManager.
sm - Containing shard map.

Method Details

add

public PointMapping add(PointMapping mapping)

Adds a point mapping.

Parameters:

mapping - Mapping being added.

Returns:

The added mapping object.

getLockOwnerForMapping

public UUID getLockOwnerForMapping(PointMapping mapping)

Gets the lock owner of a mapping.

Parameters:

mapping - The mapping

Returns:

Lock owner for the mapping.

getMappingsForRange

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

Gets all the mappings that exist within given range.

Parameters:

range - Optional range value, if null, we cover everything.
shard - Optional shard parameter, if null, we cover all shards.
lookupOptions - Whether to use cache and/or storage for lookups.

Returns:

Read-only collection of mappings that overlap with given range.

lockOrUnlockMappings

public void lockOrUnlockMappings(PointMapping mapping, UUID lockOwnerId, LockOwnerIdOpType lockOwnerIdOpType)

Locks or unlocks a given mapping or all mappings.

Parameters:

mapping - Optional mapping
lockOwnerId - The lock owner id
lockOwnerIdOpType - Operation to perform on this mapping with the given lockOwnerId

lookup

public PointMapping lookup(Object key, LookupOptions lookupOptions)

Looks up the key value and returns the corresponding mapping.

Parameters:

key - Input key value.
lookupOptions - Whether to use cache and/or storage for lookups.

Returns:

Mapping that contains the key value.

markMappingOffline

public PointMapping markMappingOffline(PointMapping mapping)

Marks the given mapping offline.

Parameters:

mapping - Input point mapping.

Returns:

An offline mapping.

markMappingOffline

public PointMapping markMappingOffline(PointMapping mapping, UUID lockOwnerId)

Marks the given mapping offline.

Parameters:

mapping - Input point mapping.
lockOwnerId - Lock owner id of this mapping

Returns:

An offline mapping.

markMappingOnline

public PointMapping markMappingOnline(PointMapping mapping)

Marks the given mapping online.

Parameters:

mapping - Input point mapping.

Returns:

An online mapping.

markMappingOnline

public PointMapping markMappingOnline(PointMapping mapping, UUID lockOwnerId)

Marks the given mapping online.

Parameters:

mapping - Input point mapping.
lockOwnerId - Lock owner id of this mapping

Returns:

An online mapping.

openConnectionForKey

public Connection openConnectionForKey(Object key, String connectionString)

Given a key value, obtains a SqlConnection to the shard in the mapping that contains the key value.

Parameters:

key - Input key value.
connectionString - Connection string with credential information, the DataSource and Database are obtained from the results of the lookup operation for key.

Returns:

An opened SqlConnection.

openConnectionForKey

public 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:

key - Input key value.
connectionString - Connection string with credential information, the DataSource and Database are obtained from the results of the lookup operation for key.
options - Options for validation operations to perform on opened connection.

Returns:

An opened SqlConnection.

openConnectionForKeyAsync

public Callable openConnectionForKeyAsync(Object key, String connectionString)

Given a key value, asynchronously obtains a SqlConnection to the shard in the mapping that contains the key value.

Parameters:

key - Input key value.
connectionString - Connection string with credential information, the DataSource and Database are obtained from the results of the lookup operation for key.

Returns:

A Task encapsulating an opened SqlConnection. All non usage-error exceptions will be reported via the returned Task

openConnectionForKeyAsync

public Callable 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.

Parameters:

key - Input key value.
connectionString - Connection string with credential information, the DataSource and Database are obtained from the results of the lookup operation for key.
options - Options for validation operations to perform on opened connection.

Returns:

A Task encapsulating an opened SqlConnection. All non usage-error exceptions will be reported via the returned Task

remove

public void remove(PointMapping mapping)

Removes a point mapping.

Parameters:

mapping - Mapping being removed.

remove

public void remove(PointMapping mapping, UUID lockOwnerId)

Removes a point mapping.

Parameters:

mapping - Mapping being removed.
lockOwnerId - Lock owner id of the mapping

tryLookup

public boolean tryLookup(Object key, LookupOptions lookupOptions, ReferenceObjectHelper mapping)

Tries to looks up the key value and returns the corresponding mapping.

Parameters:

key - Input key value.
lookupOptions - Whether to use cache and/or storage for lookups.
mapping - Mapping that contains the key value.

Returns:

true if mapping is found, false otherwise.

update

public PointMapping update(PointMapping currentMapping, PointMappingUpdate update)

Allows for update to a point mapping with the updates provided in the update parameter.

Parameters:

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

Returns:

New instance of mapping with updated information.

update

public PointMapping update(PointMapping currentMapping, PointMappingUpdate update, UUID lockOwnerId)

Allows for update to a point mapping with the updates provided in the update parameter.

Parameters:

currentMapping - Mapping being updated.
update - Updated properties of the Shard.
lockOwnerId - Lock owner id of this mapping

Returns:

New instance of mapping with updated information.

Applies to