Aracılığıyla paylaş


ShardMapManager Class

  • java.lang.Object
    • com.microsoft.azure.elasticdb.shard.mapmanager.ShardMapManager

public class ShardMapManager

Serves as the entry point for creation, management and lookup operations over shard maps.

Field Summary

Modifier and Type Field and Description
Event<EventHandler<RetryingEventArgs>> shardMapManagerRetrying

Event to be raised on Shard Map Manager store retries.

Constructor Summary

Constructor Description
ShardMapManager(SqlShardMapManagerCredentials credentials, IStoreConnectionFactory storeConnectionFactory, IStoreOperationFactory storeOperationFactory, ICacheStore cacheStore, ShardMapManagerLoadPolicy loadPolicy, RetryPolicy retryPolicy, RetryBehavior retryBehavior)

Given the connection string, opens up the corresponding data source and obtains the ShardMapManager.

ShardMapManager(SqlShardMapManagerCredentials credentials, IStoreConnectionFactory storeConnectionFactory, IStoreOperationFactory storeOperationFactory, ICacheStore cacheStore, ShardMapManagerLoadPolicy loadPolicy, RetryPolicy retryPolicy, RetryBehavior retryBehavior, EventHandler<RetryingEventArgs> retryEventHandler)

Given the connection string, opens up the corresponding data source and obtains the ShardMapManager.

Method Summary

Modifier and Type Method and Description
<KeyT> ListShardMap<KeyT> createListShardMap(String shardMapName, ShardKeyType keyType)

Creates a list based ListShardMap<KeyT>.

<KeyT> RangeShardMap<KeyT> createRangeShardMap(String shardMapName, ShardKeyType keyType)

Create a range based RangeShardMap<KeyT>.

void deleteShardMap(ShardMap shardMap)

Removes the specified shard map.

ICacheStore getCache()
SqlShardMapManagerCredentials getCredentials()
List<ShardLocation> getDistinctShardLocations()

Obtains distinct shard locations from the shard map manager.

<KeyT> ListShardMap<KeyT> getListShardMap(String shardMapName, ShardKeyType keyType)

Obtains a ListShardMap<KeyT> given the name.

<KeyT> RangeShardMap<KeyT> getRangeShardMap(String shardMapName, ShardKeyType keyType)

Obtains a RangeShardMap<KeyT> given the name.

RecoveryManager getRecoveryManager()

Obtains the recovery manager for the current shard map manager instance.

RetryPolicy getRetryPolicy()
SchemaInfoCollection getSchemaInfoCollection()

Obtains the schema info collection object for the current shard map manager instance.

ShardMap getShardMap(String shardMapName)

Obtains a ShardMap given the name.

List<ShardMap> getShardMaps()

Obtains all shard maps associated with the shard map manager.

IStoreConnectionFactory getStoreConnectionFactory()
IStoreOperationFactory getStoreOperationFactory()
ShardMap lookupShardMapByName(String operationName, String shardMapName, boolean lookInCacheFirst)

Finds a shard map from cache if requested and if necessary from global shard map.

void onShardMapManagerRetryingEvent(RetryingEventArgs arg)

Publisher for ShardMapManagerRetryingEvent event.

void shardMapManagerRetryingEventHandler(Object sender, RetryingEventArgs arg)

Subscriber function to RetryPolicy.retrying event.

<KeyT> boolean tryGetListShardMap(String shardMapName, ShardKeyType keyType, ReferenceObjectHelper<ListShardMap<KeyT>> shardMap)

Tries to obtains a ListShardMap<KeyT> given the name.

<KeyT> boolean tryGetRangeShardMap(String shardMapName, ShardKeyType keyType, ReferenceObjectHelper<RangeShardMap<KeyT>> shardMap)

Tries to obtains a RangeShardMap<KeyT> given the name.

boolean tryGetShardMap(String shardMapName, ShardKeyType keyType, ReferenceObjectHelper<ShardMap> shardMap)

Tries to obtains a ShardMap given the name.

void upgradeGlobalStore()

Upgrades store hosting global shard map to the latest version supported by library.

void upgradeGlobalStore(Version targetVersion)

Upgrades store hosting global shard map to specified version. This will be used for upgrade testing.

void upgradeLocalStore(ShardLocation location)

Upgrades store location to the latest version supported by library.

void upgradeLocalStore(ShardLocation location, Version targetVersion)

Upgrades store location to the specified version. This will be used for upgrade testing.

Field Details

shardMapManagerRetrying

public Event> shardMapManagerRetrying

Event to be raised on Shard Map Manager store retries.

Constructor Details

ShardMapManager

public ShardMapManager(SqlShardMapManagerCredentials credentials, IStoreConnectionFactory storeConnectionFactory, IStoreOperationFactory storeOperationFactory, ICacheStore cacheStore, ShardMapManagerLoadPolicy loadPolicy, RetryPolicy retryPolicy, RetryBehavior retryBehavior)

Given the connection string, opens up the corresponding data source and obtains the ShardMapManager.

Parameters:

credentials - credentials for performing ShardMapManager operations.
storeConnectionFactory - Factory for store connections.
storeOperationFactory - Factory for store operations.
cacheStore - Cache store.
loadPolicy - Initialization policy.
retryPolicy - Policy for performing retries on connections to shard map manager database.
retryBehavior - Policy for detecting transient errors.

ShardMapManager

public ShardMapManager(SqlShardMapManagerCredentials credentials, IStoreConnectionFactory storeConnectionFactory, IStoreOperationFactory storeOperationFactory, ICacheStore cacheStore, ShardMapManagerLoadPolicy loadPolicy, RetryPolicy retryPolicy, RetryBehavior retryBehavior, EventHandler retryEventHandler)

Given the connection string, opens up the corresponding data source and obtains the ShardMapManager.

Parameters:

credentials - credentials for performing ShardMapManager operations.
storeConnectionFactory - Factory for store connections.
storeOperationFactory - Factory for store operations.
cacheStore - Cache store.
loadPolicy - Initialization policy.
retryPolicy - Policy for performing retries on connections to shard map manager database.
retryBehavior - Policy for detecting transient errors.
retryEventHandler - Event handler for store operation retry events.

Method Details

createListShardMap

public ListShardMap createListShardMap(String shardMapName, ShardKeyType keyType)

Creates a list based ListShardMap<KeyT>.

Parameters:

shardMapName - Name of shard map.
keyType

Returns:

List shard map with the specified name.

createRangeShardMap

public RangeShardMap createRangeShardMap(String shardMapName, ShardKeyType keyType)

Create a range based RangeShardMap<KeyT>.

Parameters:

shardMapName - Name of shard map.
keyType

Returns:

Range shard map with the specified name.

deleteShardMap

public void deleteShardMap(ShardMap shardMap)

Removes the specified shard map.

Parameters:

shardMap - ShardMap to be removed.

getCache

public ICacheStore getCache()

getCredentials

public SqlShardMapManagerCredentials getCredentials()

getDistinctShardLocations

public List getDistinctShardLocations()

Obtains distinct shard locations from the shard map manager.

Returns:

Collection of shard locations associated with the shard map manager.

getListShardMap

public ListShardMap getListShardMap(String shardMapName, ShardKeyType keyType)

Obtains a ListShardMap<KeyT> given the name.

Parameters:

shardMapName - Name of shard map.
keyType

Returns:

Resulting ShardMap.

getRangeShardMap

public RangeShardMap getRangeShardMap(String shardMapName, ShardKeyType keyType)

Obtains a RangeShardMap<KeyT> given the name.

Parameters:

shardMapName - Name of shard map.
keyType

Returns:

Resulting ShardMap.

getRecoveryManager

public RecoveryManager getRecoveryManager()

Obtains the recovery manager for the current shard map manager instance.

Returns:

Recovery manager for the shard map manager.

getRetryPolicy

public RetryPolicy getRetryPolicy()

getSchemaInfoCollection

public SchemaInfoCollection getSchemaInfoCollection()

Obtains the schema info collection object for the current shard map manager instance.

Returns:

schema info collection for shard map manager.

getShardMap

public ShardMap getShardMap(String shardMapName)

Obtains a ShardMap given the name.

Parameters:

shardMapName - Name of shard map.

Returns:

ShardMap with the specificed name.

getShardMaps

public List getShardMaps()

Obtains all shard maps associated with the shard map manager.

Returns:

Collection of shard maps associated with the shard map manager.

getStoreConnectionFactory

public IStoreConnectionFactory getStoreConnectionFactory()

getStoreOperationFactory

public IStoreOperationFactory getStoreOperationFactory()

lookupShardMapByName

public ShardMap lookupShardMapByName(String operationName, String shardMapName, boolean lookInCacheFirst)

Finds a shard map from cache if requested and if necessary from global shard map.

Parameters:

operationName - Operation name, useful for diagnostics.
shardMapName - Name of shard map.
lookInCacheFirst - Whether to skip first lookup in cache.

Returns:

Shard map object corresponding to one being searched.

onShardMapManagerRetryingEvent

public void onShardMapManagerRetryingEvent(RetryingEventArgs arg)

Publisher for ShardMapManagerRetryingEvent event.

Parameters:

arg - Event argument.

shardMapManagerRetryingEventHandler

public void shardMapManagerRetryingEventHandler(Object sender, RetryingEventArgs arg)

Subscriber function to RetryPolicy.retrying event.

Parameters:

sender - Sender object (RetryPolicy)
arg - Event argument.

tryGetListShardMap

public boolean tryGetListShardMap(String shardMapName, ShardKeyType keyType, ReferenceObjectHelper> shardMap)

Tries to obtains a ListShardMap<KeyT> given the name.

Parameters:

shardMapName - Name of shard map.
keyType
shardMap

Returns:

ListShardMap

tryGetRangeShardMap

public boolean tryGetRangeShardMap(String shardMapName, ShardKeyType keyType, ReferenceObjectHelper> shardMap)

Tries to obtains a RangeShardMap<KeyT> given the name.

Parameters:

shardMapName - Name of shard map.
keyType
shardMap

Returns:

RangeShardMap

tryGetShardMap

public boolean tryGetShardMap(String shardMapName, ShardKeyType keyType, ReferenceObjectHelper shardMap)

Tries to obtains a ShardMap given the name.

Parameters:

shardMapName - Name of shard map.
keyType
shardMap - Shard map with the specified name.

Returns:

true if shard map with the specified name was found, false otherwise.

upgradeGlobalStore

public void upgradeGlobalStore()

Upgrades store hosting global shard map to the latest version supported by library.

upgradeGlobalStore

public void upgradeGlobalStore(Version targetVersion)

Upgrades store hosting global shard map to specified version. This will be used for upgrade testing.

Parameters:

targetVersion - Target store version to deploy.

upgradeLocalStore

public void upgradeLocalStore(ShardLocation location)

Upgrades store location to the latest version supported by library.

Parameters:

location - Shard location to upgrade.

upgradeLocalStore

public void upgradeLocalStore(ShardLocation location, Version targetVersion)

Upgrades store location to the specified version. This will be used for upgrade testing.

Parameters:

location - Shard location to upgrade.
targetVersion - Target store version to deploy.

Applies to