ShardMap Class
- java.
lang. Object - Cloneable
- com.
microsoft. azure. elasticdb. shard. map. ShardMap
- com.
public class ShardMap
Represents a collection of shards and mappings between keys and shards in the collection.
Field Summary
Modifier and Type | Field and Description |
---|---|
Shard |
shardMapManager
Reference to ShardMapManager. |
Store |
storeShardMap
Storage representation. |
Constructor Summary
Constructor | Description |
---|---|
ShardMap(ShardMapManager shardMapManager, StoreShardMap ssm) |
Constructs an instance of ShardMap. |
Method Summary
Modifier and Type | Method and Description |
---|---|
Shard |
clone()
Clones the given shard map. |
abstract Shard |
cloneCore()
Clones the current shard map instance. |
final Shard |
createShard(ShardCreationInfo shardCreationArgs)
Creates a new shard and registers it with the shard map. |
final Shard |
createShard(ShardLocation location)
Atomically adds a shard to ShardMap using the specified location. |
final void |
deleteShard(Shard shard)
Removes a shard from ShardMap. |
final String | getApplicationNameSuffix() |
final UUID |
getId()
Identity. |
final Shard |
getKeyType()
Shard map key type. |
abstract<V> IShard |
getMapper()
Gets the mapper. This method is used by OpenConnection and Lookup of V. |
final Shard |
getMapType()
Shard map type. |
String |
getName()
Shard map name. |
final Shard |
getShard(ShardLocation location)
Obtains the shard for the specified location. |
final Shard |
getShardMapManager() |
final List<Shard> |
getShards()
Gets all shards from the shard map. |
final Store |
getStoreShardMap() |
final Connection |
openConnection(IShardProvider shardProvider, String connectionString)
Opens a connection to the given shard provider. |
final Connection |
openConnection(IShardProvider shardProvider, String connectionString, ConnectionOptions options)
Opens a connection to the given shard provider. |
final Callable<Connection> |
openConnectionAsync(IShardProvider shardProvider, String connectionString)
Asynchronously opens a connection to the given shard provider. |
final Callable<Connection> |
openConnectionAsync(IShardProvider shardProvider, String connectionString, ConnectionOptions options)
Asynchronously opens a connection to the given shard provider. All exceptions are reported via the returned task. |
<KeyT> Connection |
openConnectionForKey(KeyT key, String connectionString)
Opens a regular SqlConnection to the shard to which the specified key value is mapped, with Validate. |
<KeyT> Connection |
openConnectionForKey(KeyT key, String connectionString, ConnectionOptions options)
Opens a regular SqlConnection to the shard to which the specified key value is mapped. |
<KeyT> Callable<Connection> |
openConnectionForKeyAsync(KeyT key, String connectionString)
Asynchronously opens a regular SqlConnection to the shard to which the specified key value is mapped, with Validate. |
<KeyT> Callable<Connection> |
openConnectionForKeyAsync(KeyT key, String connectionString, ConnectionOptions options)
Asynchronously opens a regular SqlConnection to the shard to which the specified key value is mapped. |
String |
toString()
Converts the object to its string representation. |
final boolean |
tryGetShard(ShardLocation location, ReferenceObjectHelper<Shard> shard)
Tries to obtains the shard for the specified location. |
final Shard |
updateShard(Shard currentShard, ShardUpdate update)
Updates a shard with the changes specified in the update parameter. |
Field Details
shardMapManager
protected ShardMapManager shardMapManager
Reference to ShardMapManager.
storeShardMap
protected StoreShardMap storeShardMap
Storage representation.
Constructor Details
ShardMap
public ShardMap(ShardMapManager shardMapManager, StoreShardMap ssm)
Constructs an instance of ShardMap.
Parameters:
Method Details
clone
public ShardMap clone()
Clones the given shard map.
Returns:
cloneCore
protected abstract ShardMap cloneCore()
Clones the current shard map instance.
Returns:
createShard
public final Shard createShard(ShardCreationInfo shardCreationArgs)
Creates a new shard and registers it with the shard map.
Parameters:
Returns:
createShard
public final Shard createShard(ShardLocation location)
Atomically adds a shard to ShardMap using the specified location.
Parameters:
Returns:
deleteShard
public final void deleteShard(Shard shard)
Removes a shard from ShardMap.
Parameters:
getApplicationNameSuffix
public final String getApplicationNameSuffix()
getId
public final UUID getId()
Identity.
getKeyType
public final ShardKeyType getKeyType()
Shard map key type.
getMapper
public abstract
Gets the mapper. This method is used by OpenConnection and Lookup of V.
Returns:
getMapType
public final ShardMapType getMapType()
Shard map type.
getName
public String getName()
Shard map name.
getShard
public final Shard getShard(ShardLocation location)
Obtains the shard for the specified location.
Parameters:
Returns:
getShardMapManager
public final ShardMapManager getShardMapManager()
getShards
public final List
Gets all shards from the shard map.
Returns:
getStoreShardMap
public final StoreShardMap getStoreShardMap()
openConnection
public final Connection openConnection(IShardProvider shardProvider, String connectionString)
Opens a connection to the given shard provider.
Parameters:
openConnection
public final Connection openConnection(IShardProvider shardProvider, String connectionString, ConnectionOptions options)
Opens a connection to the given shard provider.
Parameters:
openConnectionAsync
public final Callable
Asynchronously opens a connection to the given shard provider.
Parameters:
Returns:
openConnectionAsync
public final Callable
Asynchronously opens a connection to the given shard provider. All exceptions are reported via the returned task.
Parameters:
Returns:
openConnectionForKey
public
Opens a regular SqlConnection to the shard to which the specified key value is mapped, with Validate.
Parameters:
Returns:
openConnectionForKey
public
Opens a regular SqlConnection to the shard to which the specified key value is mapped.
Parameters:
Returns:
openConnectionForKeyAsync
public
Asynchronously opens a regular SqlConnection to the shard to which the specified key value is mapped, with Validate.
Parameters:
Returns:
openConnectionForKeyAsync
public
Asynchronously opens a regular SqlConnection to the shard to which the specified key value is mapped.
Parameters:
Returns:
toString
public String toString()
Converts the object to its string representation.
Returns:
tryGetShard
public final boolean tryGetShard(ShardLocation location, ReferenceObjectHelper
Tries to obtains the shard for the specified location.
Parameters:
Returns:
true
if shard with specified location is found, false
otherwise.
updateShard
public final Shard updateShard(Shard currentShard, ShardUpdate update)
Updates a shard with the changes specified in the update parameter.
Parameters:
Returns: