你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
MultiShardConnection Class
- java.
lang. Object - AutoCloseable
- com.
microsoft. azure. elasticdb. query. multishard. MultiShardConnection
- com.
public class MultiShardConnection
Represents a connection to a set of shards and provides the ability to process queries across the shard set. Purpose: Creates connections to the given set of shards and governs their lifetime Notes: This class is NOT thread-safe.
Field Summary
Modifier and Type | Field and Description |
---|---|
String |
ApplicationNameSuffix
The suffix to append to each shard's ApplicationName. Will help with server-side telemetry. |
Constructor Summary
Constructor | Description |
---|---|
MultiShardConnection(ArrayList<Pair<ShardLocation, Connection>> shardConnections) |
Creates an instance of this class. TEST ONLY |
MultiShardConnection(String connectionString, Shard... shards) |
Initializes a new instance of the MultiShardConnection class. Multiple Active Result Sets (MARS) are not supported and are disabled for any processing at the shards. |
MultiShardConnection(String connectionString, ShardLocation... shardLocations) |
Initializes a new instance of the MultiShardConnection class. Multiple Active Result Sets (MARS) are not supported and are disabled for any processing at the shards. |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases all resources used by this object. |
void |
closeOpenConnections()
Closes any open connections to shards. Does a best-effort close and doesn't throw. |
Multi |
createCommand()
Creates and returns a MultiShardStatement object. The MultiShardStatement object can then be used to execute a command against all shards specified in the connection. |
String |
getConnectionString()
Gets the connection string associated with this connection. |
List<Pair<Shard |
getShardConnections()
Gets the collection of ShardLocations and Connections associated with this connection. |
List<Shard |
getShardLocations()
Gets the collection of ShardLocations associated with this connection. |
List<Shard> |
getShards()
Gets the collection of Shards associated with this connection. |
boolean |
isClosed()
Check if connection is closed or not. |
Field Details
ApplicationNameSuffix
public static String ApplicationNameSuffix= "ESC_MSQv" + GlobalConstants.MultiShardQueryVersionInfo
The suffix to append to each shard's ApplicationName. Will help with server-side telemetry.
Constructor Details
MultiShardConnection
public MultiShardConnection(ArrayList
Creates an instance of this class. TEST ONLY
Parameters:
MultiShardConnection
public MultiShardConnection(String connectionString, Shard... shards)
Initializes a new instance of the MultiShardConnection class.
Multiple Active Result Sets (MARS) are not supported and are disabled for any processing at the shards.
Parameters:
MultiShardConnection
public MultiShardConnection(String connectionString, ShardLocation... shardLocations)
Initializes a new instance of the MultiShardConnection class.
Multiple Active Result Sets (MARS) are not supported and are disabled for any processing at the shards.
Parameters:
Method Details
close
public void close()
Releases all resources used by this object.
closeOpenConnections
public void closeOpenConnections()
Closes any open connections to shards. Does a best-effort close and doesn't throw.
createCommand
public MultiShardStatement createCommand()
Creates and returns a MultiShardStatement object. The MultiShardStatement object can then be used to execute a command against all shards specified in the connection.
Returns:
getConnectionString
public String getConnectionString()
Gets the connection string associated with this connection.
getShardConnections
public List
Gets the collection of ShardLocations and Connections associated with this connection.
getShardLocations
public List
Gets the collection of ShardLocations associated with this connection.
getShards
public List
Gets the collection of Shards associated with this connection.
isClosed
public boolean isClosed()
Check if connection is closed or not.
Returns: