RecoveryManager Class
- java.
lang. Object - com.
microsoft. azure. elasticdb. shard. recovery. RecoveryManager
- com.
public class RecoveryManager
Manages various recovery related tasks for a shard map manager. It helps resolving data corruption issues between shard map information stored locally on the shards and in the global shard map manager database. It also helps with certain 'oops' recovery scenarios where reconstruction of shard maps from database backups or database copies is necessary. Note that some of the recovery methods can cause unrecoverable data loss when not used properly. It is recommend to take backups or copies of all databases that participate in recovery operations.
Constructor Summary
Constructor | Description |
---|---|
RecoveryManager(ShardMapManager shardMapManager) |
Constructs an instance of the recovery manager for given shard map manager. |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
attachShard(ShardLocation location)
Attaches a shard to the shard map manager. Earlier versions of mappings for the same shard map will automatically be updated if more recent versions are found on the shard to be attached. After attaching a shard, DetectMappingDifferences(ShardLocation, string) should be called to check for any inconsistencies that warrant manual conflict resolution. |
void |
attachShard(ShardLocation location, String shardMapName)
Attaches a shard to the shard map manager. Earlier versions of mappings for the same shard map will automatically be updated if more recent versions are found on the shard to be attached. Shard location will be upgraded to latest version of local store as part of this operation. After attaching a shard, DetectMappingDifferences(ShardLocation, string) should be called to check for any inconsistencies that warrant manual conflict resolution. |
void |
detachShard(ShardLocation location)
Detaches the given shard from the shard map manager. Mappings pointing to the shard to be deleted will automatically be removed by this method. |
void |
detachShard(ShardLocation location, String shardMapName)
Detaches the given shard from the shard map manager. Mappings pointing to the shard to be deleted will automatically be removed by this method. |
List<Recovery |
detectMappingDifferences(ShardLocation location)
Enumerates differences in the mappings between the global shard map manager database and the local shard database in the specified shard location. |
List<Recovery |
detectMappingDifferences(ShardLocation location, String shardMapName)
Enumerates differences in the mappings between the global shard map manager database and the local shard database in the specified shard location. |
Map<Shard |
getMappingDifferences(RecoveryToken token)
Returns a dictionary of range-to-location key-value pairs. The location returned is an enumerator stating whether a given range (or point) is present only in the local shard map, only in the global shard map, or both. Ranges not contained in either shard map cannot contain differences so those ranges are not shown. |
void |
getShardInfo(RecoveryToken token, ReferenceObjectHelper<ShardMapType> mapType, ReferenceObjectHelper<String> shardMapName)
Retrieves shard map type and name based on the token returned from DetectMappingDifferences(ShardLocation, string). |
void |
getShardInfo(RecoveryToken token, ReferenceObjectHelper<ShardMapType> mapType, ReferenceObjectHelper<String> shardMapName, ReferenceObjectHelper<ShardLocation> shardLocation)
Retrieves shard map type, name and shard location based on the token returned from DetectMappingDifferences(ShardLocation, string). |
Shard |
getShardLocation(RecoveryToken token)
Returns the shard location of the local shard map processed by DetectMappingDifferences(ShardLocation, string). |
String |
getShardMapName(RecoveryToken token)
Returns the shard map name of the shard map processed by DetectMappingDifferences(ShardLocation, string). |
Shard |
getShardMapType(RecoveryToken token)
Returns the shard map type of the shard map processed by DetectMappingDifferences(ShardLocation, string). |
void |
rebuildMappingsOnShard(RecoveryToken token, List<ShardRange> ranges)
Rebuilds a local range shard map from a list of inconsistent shard ranges detected by DetectMappingDifferences(ShardLocation, string) and then accessed by GetMappingDifferences. The resulting local range shard map will always still be inconsistent with the global shard map in the shard map manager database. A subsequent call to ResolveMappingDifferences is necessary to bring the system back to a healthy state. |
void |
rebuildMappingsOnShardMapManagerFromShards(List<ShardLocation> shardLocations)
Given a collection of shard locations, reconstructs the shard map manager based on mapping information stored in the individual shards. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map. If the information in the individual shard maps is or becomes inconsistent, the behavior is undefined. No cross shard locks are taken, so if any shards become inconsistent during the execution of this method, the final state of the global shard map may be corrupt. |
void |
rebuildMappingsOnShardMapManagerFromShards(List<ShardLocation> shardLocations, String shardMapName)
Given a collection of shard locations, reconstructs the shard map manager based on mapping information stored in the individual shards. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map. If the information in the individual shard maps is or becomes inconsistent, the behavior is undefined. No cross shard locks are taken, so if any shards become inconsistent during the execution of this method, the final state of the global shard map may be corrupt. |
void |
rebuildMappingsOnShardsFromShardMapManager(List<ShardLocation> shardLocations)
Given a collection of shard locations, reconstructs local shard maps based on the mapping information stored in the global shard map. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map. |
void |
rebuildMappingsOnShardsFromShardMapManager(List<ShardLocation> shardLocations, String shardMapName)
Given a collection of shard locations, reconstructs local shard maps based on the mapping information stored in the global shard map. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map. |
void |
resolveMappingDifferences(RecoveryToken token, MappingDifferenceResolution resolution)
Selects one of the shard maps (either local or global) as a source of truth and brings mappings on both shard maps in sync. |
Constructor Details
RecoveryManager
public RecoveryManager(ShardMapManager shardMapManager)
Constructs an instance of the recovery manager for given shard map manager.
Parameters:
Method Details
attachShard
public void attachShard(ShardLocation location)
Attaches a shard to the shard map manager. Earlier versions of mappings for the same shard map will automatically be updated if more recent versions are found on the shard to be attached. After attaching a shard, DetectMappingDifferences(ShardLocation, string) should be called to check for any inconsistencies that warrant manual conflict resolution.
Parameters:
attachShard
public void attachShard(ShardLocation location, String shardMapName)
Attaches a shard to the shard map manager. Earlier versions of mappings for the same shard map will automatically be updated if more recent versions are found on the shard to be attached. Shard location will be upgraded to latest version of local store as part of this operation. After attaching a shard, DetectMappingDifferences(ShardLocation, string) should be called to check for any inconsistencies that warrant manual conflict resolution.
Parameters:
detachShard
public void detachShard(ShardLocation location)
Detaches the given shard from the shard map manager. Mappings pointing to the shard to be deleted will automatically be removed by this method.
Parameters:
detachShard
public void detachShard(ShardLocation location, String shardMapName)
Detaches the given shard from the shard map manager. Mappings pointing to the shard to be deleted will automatically be removed by this method.
Parameters:
detectMappingDifferences
public List
Enumerates differences in the mappings between the global shard map manager database and the local shard database in the specified shard location.
Parameters:
Returns:
detectMappingDifferences
public List
Enumerates differences in the mappings between the global shard map manager database and the local shard database in the specified shard location.
Parameters:
Returns:
getMappingDifferences
public Map
Returns a dictionary of range-to-location key-value pairs. The location returned is an enumerator stating whether a given range (or point) is present only in the local shard map, only in the global shard map, or both. Ranges not contained in either shard map cannot contain differences so those ranges are not shown.
Parameters:
Returns:
getShardInfo
public void getShardInfo(RecoveryToken token, ReferenceObjectHelper
Retrieves shard map type and name based on the token returned from DetectMappingDifferences(ShardLocation, string).
Parameters:
getShardInfo
public void getShardInfo(RecoveryToken token, ReferenceObjectHelper
Retrieves shard map type, name and shard location based on the token returned from DetectMappingDifferences(ShardLocation, string).
Parameters:
getShardLocation
public ShardLocation getShardLocation(RecoveryToken token)
Returns the shard location of the local shard map processed by DetectMappingDifferences(ShardLocation, string).
Parameters:
Returns:
getShardMapName
public String getShardMapName(RecoveryToken token)
Returns the shard map name of the shard map processed by DetectMappingDifferences(ShardLocation, string).
Parameters:
Returns:
getShardMapType
public ShardMapType getShardMapType(RecoveryToken token)
Returns the shard map type of the shard map processed by DetectMappingDifferences(ShardLocation, string).
Parameters:
Returns:
rebuildMappingsOnShard
public void rebuildMappingsOnShard(RecoveryToken token, List
Rebuilds a local range shard map from a list of inconsistent shard ranges detected by DetectMappingDifferences(ShardLocation, string) and then accessed by GetMappingDifferences. The resulting local range shard map will always still be inconsistent with the global shard map in the shard map manager database. A subsequent call to ResolveMappingDifferences is necessary to bring the system back to a healthy state.
Parameters:
rebuildMappingsOnShardMapManagerFromShards
public void rebuildMappingsOnShardMapManagerFromShards(List
Given a collection of shard locations, reconstructs the shard map manager based on mapping information stored in the individual shards. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map. If the information in the individual shard maps is or becomes inconsistent, the behavior is undefined. No cross shard locks are taken, so if any shards become inconsistent during the execution of this method, the final state of the global shard map may be corrupt.
Parameters:
rebuildMappingsOnShardMapManagerFromShards
public void rebuildMappingsOnShardMapManagerFromShards(List
Given a collection of shard locations, reconstructs the shard map manager based on mapping information stored in the individual shards. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map. If the information in the individual shard maps is or becomes inconsistent, the behavior is undefined. No cross shard locks are taken, so if any shards become inconsistent during the execution of this method, the final state of the global shard map may be corrupt.
Parameters:
rebuildMappingsOnShardsFromShardMapManager
public void rebuildMappingsOnShardsFromShardMapManager(List
Given a collection of shard locations, reconstructs local shard maps based on the mapping information stored in the global shard map. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map.
Parameters:
rebuildMappingsOnShardsFromShardMapManager
public void rebuildMappingsOnShardsFromShardMapManager(List
Given a collection of shard locations, reconstructs local shard maps based on the mapping information stored in the global shard map. The specified shards need to be registered already in the global shard map. This method only rebuilds mappings. It does not rebuild shard membership within the global shard map.
Parameters:
resolveMappingDifferences
public void resolveMappingDifferences(RecoveryToken token, MappingDifferenceResolution resolution)
Selects one of the shard maps (either local or global) as a source of truth and brings mappings on both shard maps in sync.
Parameters:
Applies to
Azure SDK for Java