Shard Class

public class Shard implements IShardProvider

Representation of a single shard. Shards are basically locators for data sources i.e. ShardLocations that have been registered with a shard map. Shards are used in mapping as targets of mappings (see PointMapping and RangeMapping).

Constructor Summary

Constructor Description
Shard(ShardMapManager shardMapManager, ShardMap shardMap, ShardCreationInfo creationInfo)

Constructs a Shard given shard creation arguments.

Shard(ShardMapManager shardMapManager, ShardMap shardMap, StoreShard storeShard)

Internal constructor that uses storage representation.

Method Summary

Modifier and Type Method and Description
Shard clone()

Clones the instance.

boolean equals(Object obj)

Determines whether the specified object is equal to the current object.

boolean equals(Shard other)

Performs equality comparison with given Shard.

UUID getId()

Identity of the shard. Each shard should have a unique one.

ShardLocation getLocation()

Gets Location of the shard.

Shard getShardInfo()

Shard for the ShardProvider object.

ShardMap getShardMap()
UUID getShardMapId()

Identify of the ShardMap this shard belongs to.

ShardMapManager getShardMapManager()
ShardStatus getStatus()

Gets the status of the shard which can be either online or offline. Connections can only be opened using Shard.OpenConnection(string, ConnectionOptions) on the shard map when the shard is online. Setting the shard status to offline prevents connections when the shard is undergoing maintenance operations.

StoreShard getStoreShard()
ShardLocation getValue()

Value corresponding to the Shard. Represents traits of the Shard object provided by the ShardInfo property.

UUID getVersion()

Shard version.

int hashCode()

Calculates the hash code for this instance.

Connection openConnection(String connectionString)

Opens a regular SqlConnection to the specified shard, with Validate.

Connection openConnection(String connectionString, ConnectionOptions options)

Opens a regular SqlConnection to the specified shard.

Callable<Connection> openConnectionAsync(String connectionString)

Asynchronously opens a regular SqlConnection to the specified shard, with Validate.

Callable<Connection> openConnectionAsync(String connectionString, ConnectionOptions options)

Asynchronously a regular SqlConnection to the specified shard.

void setShardMap(ShardMap value)
void setShardMapManager(ShardMapManager value)
void setStoreShard(StoreShard value)
String toString()

Converts the object to its string representation.

void validate(StoreShardMap shardMap, Connection conn)

Performs validation that the local representation is as up-to-date as the representation on the backing data store.

Callable validateAsync(StoreShardMap shardMap, Connection conn)

Asynchronously performs validation that the local representation is as up-to-date as the representation on the backing data store.

Constructor Details

Shard

public Shard(ShardMapManager shardMapManager, ShardMap shardMap, ShardCreationInfo creationInfo)

Constructs a Shard given shard creation arguments.

Parameters:

shardMapManager - Owning ShardMapManager.
shardMap - Owning shard map.
creationInfo - Shard creation information.

Shard

public Shard(ShardMapManager shardMapManager, ShardMap shardMap, StoreShard storeShard)

Internal constructor that uses storage representation.

Parameters:

shardMapManager - Owning ShardMapManager.
shardMap - Owning shard map.
storeShard - Storage representation of the shard.

Method Details

clone

public Shard clone()

Clones the instance.

Returns:

clone of the instance.

equals

public boolean equals(Object obj)

Determines whether the specified object is equal to the current object.

Parameters:

obj - The object to compare with the current object.

Returns:

True if the specified object is equal to the current object; otherwise, false.

equals

public boolean equals(Shard other)

Performs equality comparison with given Shard.

Parameters:

other - Shard to compare with.

Returns:

True if this object is equal to other object, false otherwise.

getId

public UUID getId()

Identity of the shard. Each shard should have a unique one.

getLocation

public ShardLocation getLocation()

Gets Location of the shard.

getShardInfo

public Shard getShardInfo()

Shard for the ShardProvider object.

getShardMap

public ShardMap getShardMap()

getShardMapId

public UUID getShardMapId()

Identify of the ShardMap this shard belongs to.

getShardMapManager

public ShardMapManager getShardMapManager()

getStatus

public ShardStatus getStatus()

Gets the status of the shard which can be either online or offline. Connections can only be opened using Shard.OpenConnection(string, ConnectionOptions) on the shard map when the shard is online. Setting the shard status to offline prevents connections when the shard is undergoing maintenance operations.

getStoreShard

public StoreShard getStoreShard()

getValue

public ShardLocation getValue()

Value corresponding to the Shard. Represents traits of the Shard object provided by the ShardInfo property.

getVersion

public UUID getVersion()

Shard version.

hashCode

public int hashCode()

Calculates the hash code for this instance.

Returns:

Hash code for the object.

openConnection

public Connection openConnection(String connectionString)

Opens a regular SqlConnection to the specified shard, with Validate.

Parameters:

connectionString - Connection string with credential information such as SQL Server credentials or Integrated Security settings. The hostname of the server and the database name for the shard are obtained from the lookup operation for key. Note that the SqlConnection object returned by this call is not protected against transient faults. Callers should follow best practices to protect the connection against transient faults in their application code, e.g., by using the transient fault handling functionality in the Enterprise Library from Microsoft Patterns and Practices team.

openConnection

public Connection openConnection(String connectionString, ConnectionOptions options)

Opens a regular SqlConnection to the specified shard.

Parameters:

connectionString - Connection string with credential information such as SQL Server credentials or Integrated Security settings. The hostname of the server and the database name for the shard are obtained from the lookup operation for key.
options - Options for validation operations to perform on opened connection. Note that the SqlConnection object returned by this call is not protected against transient faults. Callers should follow best practices to protect the connection against transient faults in their application code, e.g., by using the transient fault handling functionality in the Enterprise Library from Microsoft Patterns and Practices team.

openConnectionAsync

public Callable openConnectionAsync(String connectionString)

Asynchronously opens a regular SqlConnection to the specified shard, with Validate.

Parameters:

connectionString - Connection string with credential information such as SQL Server credentials or Integrated Security settings. The hostname of the server and the database name for the shard are obtained from the lookup operation for key.

Returns:

A Task encapsulating an opened SqlConnection Note that the SqlConnection object returned by this call is not protected against transient faults. Callers should follow best practices to protect the connection against transient faults in their application code, e.g., by using the transient fault handling functionality in the Enterprise Library from Microsoft Patterns and Practices team. All non-usage errors will be propagated via the returned Task.

openConnectionAsync

public Callable openConnectionAsync(String connectionString, ConnectionOptions options)

Asynchronously a regular SqlConnection to the specified shard.

Parameters:

connectionString - Connection string with credential information such as SQL Server credentials or Integrated Security settings. The hostname of the server and the database name for the shard are obtained from the lookup operation for key.
options - Options for validation operations to perform on opened connection.

Returns:

A Task encapsulating an opened SqlConnection Note that the SqlConnection object returned by this call is not protected against transient faults. Callers should follow best practices to protect the connection against transient faults in their application code, e.g., by using the transient fault handling functionality in the Enterprise Library from Microsoft Patterns and Practices team. All non-usage errors will be propagated via the returned Task.

setShardMap

public void setShardMap(ShardMap value)

Parameters:

value

setShardMapManager

public void setShardMapManager(ShardMapManager value)

Parameters:

value

setStoreShard

public void setStoreShard(StoreShard value)

Parameters:

value

toString

public String toString()

Converts the object to its string representation.

Returns:

String representation of the object.

validate

public void validate(StoreShardMap shardMap, Connection conn)

Performs validation that the local representation is as up-to-date as the representation on the backing data store.

Parameters:

shardMap - Shard map to which the shard provider belongs.
conn - Connection used for validation.

validateAsync

public Callable validateAsync(StoreShardMap shardMap, Connection conn)

Asynchronously performs validation that the local representation is as up-to-date as the representation on the backing data store.

Parameters:

shardMap - Shard map to which the shard provider belongs.
conn - Connection used for validation.

Returns:

A task to await validation completion

Applies to