Share via


ReliableStateManager.IReliableStateManager.GetOrAddAsync Method

Definition

Overloads

IReliableStateManager.GetOrAddAsync<T>(Uri, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(ITransaction, String, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(ITransaction, Uri, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(String)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(Uri)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(ITransaction, String)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(ITransaction, Uri)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(String, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

IReliableStateManager.GetOrAddAsync<T>(Uri, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (Uri name, TimeSpan timeout) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Uri * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Uri * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (name As Uri, timeout As TimeSpan) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

name
Uri

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

timeout
TimeSpan

The amount of time to wait for the operation to complete before throwing a TimeoutException. Primarily used to prevent deadlocks. The default is 4 seconds.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T, or timeout is negative.

The operation failed to complete within the given timeout.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created.

Applies to

IReliableStateManager.GetOrAddAsync<T>(ITransaction, String, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (Microsoft.ServiceFabric.Data.ITransaction tx, string name, TimeSpan timeout) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * string * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * string * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (tx As ITransaction, name As String, timeout As TimeSpan) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

tx
ITransaction

Transaction to associate this operation with.

name
String

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

timeout
TimeSpan

The amount of time to wait for the operation to complete before throwing a TimeoutException. Primarily used to prevent deadlocks. The default is 4 seconds.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

tx is null, or name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T, or timeout is negative.

The operation failed to complete within the given timeout.

Thrown when a method call is invalid for the object's current state. For example, transaction used is already terminated: committed or aborted.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created. If this method throws an exception, the transaction must be aborted.

Applies to

IReliableStateManager.GetOrAddAsync<T>(ITransaction, Uri, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (Microsoft.ServiceFabric.Data.ITransaction tx, Uri name, TimeSpan timeout) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * Uri * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * Uri * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (tx As ITransaction, name As Uri, timeout As TimeSpan) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

tx
ITransaction

Transaction to associate this operation with.

name
Uri

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

timeout
TimeSpan

The amount of time to wait for the operation to complete before throwing a TimeoutException. Primarily used to prevent deadlocks. The default is 4 seconds.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

tx is null, or name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T, or timeout is negative.

The operation failed to complete within the given timeout.

Thrown when a method call is invalid for the object's current state. For example, transaction used is already terminated: committed or aborted.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created. If this method throws an exception, the transaction must be aborted.

Applies to

IReliableStateManager.GetOrAddAsync<T>(String)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (string name) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : string -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : string -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (name As String) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

name
String

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T.

The operation failed to complete within the default timeout.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created.

Applies to

IReliableStateManager.GetOrAddAsync<T>(Uri)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (Uri name) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Uri -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Uri -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (name As Uri) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

name
Uri

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T.

The operation failed to complete within the default timeout.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created.

Applies to

IReliableStateManager.GetOrAddAsync<T>(ITransaction, String)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (Microsoft.ServiceFabric.Data.ITransaction tx, string name) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * string -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * string -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (tx As ITransaction, name As String) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

tx
ITransaction

Transaction to associate this operation with.

name
String

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

tx is null, or name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T.

The operation failed to complete within the default timeout.

Thrown when a method call is invalid for the object's current state. For example, transaction used is already terminated: committed or aborted.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created. If this method throws an exception, the transaction must be aborted.

Applies to

IReliableStateManager.GetOrAddAsync<T>(ITransaction, Uri)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (Microsoft.ServiceFabric.Data.ITransaction tx, Uri name) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * Uri -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : Microsoft.ServiceFabric.Data.ITransaction * Uri -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (tx As ITransaction, name As Uri) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

tx
ITransaction

Transaction to associate this operation with.

name
Uri

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

tx is null, or name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T.

The operation failed to complete within the default timeout.

Thrown when a method call is invalid for the object's current state. For example, transaction used is already terminated: committed or aborted.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created. If this method throws an exception, the transaction must be aborted.

Applies to

IReliableStateManager.GetOrAddAsync<T>(String, TimeSpan)

Gets an IReliableState of the given type T and with the given name if it exists, or creates one and returns it if it doesn't already exist.

System.Threading.Tasks.Task<T> IReliableStateManager.GetOrAddAsync<T> (string name, TimeSpan timeout) where T : Microsoft.ServiceFabric.Data.IReliableState;
abstract member Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : string * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
override this.Microsoft.ServiceFabric.Data.IReliableStateManager.GetOrAddAsync : string * TimeSpan -> System.Threading.Tasks.Task<'T (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)> (requires 'T :> Microsoft.ServiceFabric.Data.IReliableState)
Function GetOrAddAsync(Of T As IReliableState) (name As String, timeout As TimeSpan) As Task(Of T) Implements IReliableStateManager.GetOrAddAsync

Type Parameters

T

When specifying the IReliableState type, you may ask for either a class type or an interface type.

If specifying a class type, the system will attempt to return an instance of that type. If an instance of that type cannot be instantiated (e.g., abstract class, no suitable constructor), an ArgumentException is thrown.

If specifying an interface type, the manager will attempt to resolve the interface to a concrete type. If type mapping is specified by the user, this method will use the user-specified mapping to resolve the type (not yet supported). If type mapping is not specified by the user this method will select the default implementation for the interface given. If the given interface type does not have a default implementation, or a user-specified mapping for the type is not provided or the type is invalid, this method will throw ArgumentException.

Parameters

name
String

The name of the IReliableState. This name must be unique in this IReliableStateManager across IReliableState types, including unrelated types.

timeout
TimeSpan

The amount of time to wait for the operation to complete before throwing a TimeoutException. Primarily used to prevent deadlocks. The default is 4 seconds.

Returns

Task<T>

Task that represents the asynchronous operation. The task result is the reliable state instance.

Implements

Exceptions

name is null.

An instance of the type T cannot be created, or the existing IReliableState instance is not of type T, or timeout is negative.

The operation failed to complete within the given timeout.

Indicates that the Reliable State Manager is closed.

Remarks

This is an atomic operation. When an IReliableState needs to be created, it will either complete and return successfully or it will not be created.

Applies to