Compartilhar via


IShardMapper<MappingT,ValueT> Interface

Type Parameters

MappingT
ValueT

public interface IShardMapper<MappingT extends IShardProvider,ValueT>

Container for a collection of keys to shards mappings.

Method Summary

Modifier and Type Method and Description
MappingT add(MappingT mapping)

Adds a mapping.

MappingT lookup(ValueT key, LookupOptions lookupOptions)

Looks up the key value and returns the corresponding mapping.

Connection openConnectionForKey(ValueT key, String connectionString)
Connection openConnectionForKey(ValueT key, String connectionString, ConnectionOptions options)

Given a key value, obtains a SqlConnection to the shard in the mapping that contains the key value.

Callable<Connection> openConnectionForKeyAsync(ValueT key, String connectionString)
Callable<Connection> openConnectionForKeyAsync(ValueT key, String connectionString, ConnectionOptions options)

Given a key value, asynchronously obtains a SqlConnection to the shard in the mapping that contains the key value.

void remove(MappingT mapping, UUID lockOwnerId)

Removes a mapping.

boolean tryLookup(ValueT key, LookupOptions lookupOptions, ReferenceObjectHelper<MappingT> mapping)

Tries to looks up the key value and returns the corresponding mapping.

Method Details

add

public MappingT add(MappingT mapping)

Adds a mapping.

Parameters:

mapping - Mapping being added.

lookup

public MappingT lookup(ValueT key, LookupOptions lookupOptions)

Looks up the key value and returns the corresponding mapping.

Parameters:

key - Input key value.
lookupOptions - Whether to use cache and/or storage for lookups.

Returns:

Mapping that contains the key value.

openConnectionForKey

public Connection openConnectionForKey(ValueT key, String connectionString)

Parameters:

key
connectionString

openConnectionForKey

public Connection openConnectionForKey(ValueT key, String connectionString, ConnectionOptions options)

Given a key value, obtains a SqlConnection to the shard in the mapping that contains the key value.

Parameters:

key - Input key value.
connectionString - Connection string with credential information, the DataSource and Database are obtained from the results of the lookup operation for key.
options - Options for validation operations to perform on opened connection.

Returns:

An opened SqlConnection.

openConnectionForKeyAsync

public Callable openConnectionForKeyAsync(ValueT key, String connectionString)

Parameters:

key
connectionString

openConnectionForKeyAsync

public Callable openConnectionForKeyAsync(ValueT key, String connectionString, ConnectionOptions options)

Given a key value, asynchronously obtains a SqlConnection to the shard in the mapping that contains the key value.

Parameters:

key - Input key value.
connectionString - Connection string with credential information, the DataSource and Database are obtained from the results of the lookup operation for key.
options - Options for validation operations to perform on opened connection.

Returns:

An opened SqlConnection.

remove

public void remove(MappingT mapping, UUID lockOwnerId)

Removes a mapping.

Parameters:

mapping - Mapping being removed.
lockOwnerId - Lock owner id of the mapping

tryLookup

public boolean tryLookup(ValueT key, LookupOptions lookupOptions, ReferenceObjectHelper mapping)

Tries to looks up the key value and returns the corresponding mapping.

Parameters:

key - Input key value.
lookupOptions - Whether to use cache and/or storage for lookups.
mapping - Mapping that contains the key value.

Returns:

true if mapping is found, false otherwise.

Applies to