你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
FabricRuntime Class
- java.
lang. Object - AutoCloseable
- system.
fabric. FabricRuntime
- system.
public class FabricRuntime
Allows user created hosts to obtain their CodePackageActivationContext, well as to register the necessary service factories [ StatelessServiceFactory, StatefulServiceFactory ] or service types directly.
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the associated FabricCodePackageActivationContext instance and release the associated runtime pointer. |
Fabric |
create()
Creates the system.fabric.FabricRuntime object. |
CompletableFuture<Fabric |
createAsync(Duration timeout)
Creates the system.fabric.FabricRuntime object asynchronously with the specified timeout parameter. |
CompletableFuture<Fabric |
createAsync(Runnable fabricExitCallback, Duration timeout)
Creates the system.fabric.FabricRuntime object asynchronously with the specified callback function which will be executed if the underlying runtime terminates or exits for any reason. |
Fabric |
getActivationContext()
Retrieves the current system.fabric.FabricRuntime's CodePackageActivationContext. |
CompletableFuture<Fabric |
getActivationContextAsync(Duration timeout)
Retrieves the current system.fabric.FabricRuntime’s CodePackageActivationContext asynchronously with the specified parameter. |
Node |
getNodeContext()
Gets the Node Context object that contains information about Fabric Node. |
CompletableFuture<Node |
getNodeContextAsync(Duration timeout)
Gets Node Context from Fabric Node asynchronously with timeout and cancellation token. |
void |
registerServiceType(String serviceTypeName, Class<?> serviceTypeImplementation)
Associates the specified serviceTypeName with the actual managed Type that implements it.
Remarks:Note that this mechanism for service type registration does not require a custom StatelessServiceFactory or StatefulServiceFactory to be provided at registration time. Service Fabric will generate one at runtime and utilize it automatically. If there is a need for a custom implementation of the factory, you can implement StatelessServiceFactory or StatefulServiceFactory and then provide those via the corresponding factory registration methods ( system.fabric.FabricRuntime#registerStatelessServiceFactoryAsync(java.lang.String, system.fabric.StatelessServiceFactory, java.time.Duration) or system.fabric.FabricRuntime#registerStatefulServiceFactoryAsync(java.lang.String, system.fabric.StatefulServiceFactory, java.time.Duration) ) |
CompletableFuture<?> |
registerServiceTypeAsync(String serviceTypeName, Class<?> serviceTypeImplementation, Duration timeout)
Asynchronously associates the specified serviceTypeName with the actual managed Type that implements it, with the specified timeout |
void |
registerStatefulServiceFactory(String serviceTypeName, StatefulServiceFactory factory)
Registers the specified StatefulServiceFactory for the specified service type. |
CompletableFuture<?> |
registerStatefulServiceFactoryAsync(String serviceTypeName, StatefulServiceFactory factory, Duration timeout)
Registers the specified StatefulServiceFactory for the specified service type with the specified timeout and cancellationToken. |
void |
registerStatelessServiceFactory(String serviceTypeName, StatelessServiceFactory factory)
Registers the specified StatelessServiceFactory for the specified service type. |
CompletableFuture<?> |
registerStatelessServiceFactoryAsync(String serviceTypeName, StatelessServiceFactory factory, Duration timeout)
Asynchronously registers the specified StatelessServiceFactory for the specified service type, with the specified timeout and cancellationToken |
Method Details
close
public void close()
Closes the associated FabricCodePackageActivationContext instance and release the associated runtime pointer.
create
public static FabricRuntime create()
Creates the system.fabric.FabricRuntime object.
Returns:
createAsync
public static CompletableFuture
Creates the system.fabric.FabricRuntime object asynchronously with the specified timeout parameter.
Parameters:
Returns:
createAsync
public static CompletableFuture
Creates the system.fabric.FabricRuntime object asynchronously with the specified callback function which will be executed if the underlying runtime terminates or exits for any reason.
Parameters:
Returns:
getActivationContext
public static FabricCodePackageActivationContext getActivationContext()
Retrieves the current system.fabric.FabricRuntime's CodePackageActivationContext.
Returns:
getActivationContextAsync
public static CompletableFuture
Retrieves the current system.fabric.FabricRuntime’s CodePackageActivationContext asynchronously with the specified parameter.
Parameters:
Returns:
getNodeContext
public static NodeContext getNodeContext()
Gets the Node Context object that contains information about Fabric Node.
Returns:
getNodeContextAsync
public static CompletableFuture
Gets Node Context from Fabric Node asynchronously with timeout and cancellation token.
Parameters:
Returns:
registerServiceType
public void registerServiceType(String serviceTypeName, Class serviceTypeImplementation)
Associates the specified serviceTypeName with the actual managed Type that implements it.
Remarks:Note that this mechanism for service type registration does not require a custom StatelessServiceFactory or StatefulServiceFactory to be provided at registration time. Service Fabric will generate one at runtime and utilize it automatically. If there is a need for a custom implementation of the factory, you can implement StatelessServiceFactory or StatefulServiceFactory and then provide those via the corresponding factory registration methods ( system.fabric.FabricRuntime#registerStatelessServiceFactoryAsync(java.lang.String, system.fabric.StatelessServiceFactory, java.time.Duration) or system.fabric.FabricRuntime#registerStatefulServiceFactoryAsync(java.lang.String, system.fabric.StatefulServiceFactory, java.time.Duration) )
Parameters:
registerServiceTypeAsync
public CompletableFuture registerServiceTypeAsync(String serviceTypeName, Class serviceTypeImplementation, Duration timeout)
Asynchronously associates the specified serviceTypeName with the actual managed Type that implements it, with the specified timeout
Parameters:
Returns:
registerStatefulServiceFactory
public void registerStatefulServiceFactory(String serviceTypeName, StatefulServiceFactory factory)
Registers the specified StatefulServiceFactory for the specified service type.
Parameters:
registerStatefulServiceFactoryAsync
public CompletableFuture registerStatefulServiceFactoryAsync(String serviceTypeName, StatefulServiceFactory factory, Duration timeout)
Registers the specified StatefulServiceFactory for the specified service type with the specified timeout and cancellationToken.
Parameters:
Returns:
registerStatelessServiceFactory
public void registerStatelessServiceFactory(String serviceTypeName, StatelessServiceFactory factory)
Registers the specified StatelessServiceFactory for the specified service type.
Parameters:
registerStatelessServiceFactoryAsync
public CompletableFuture registerStatelessServiceFactoryAsync(String serviceTypeName, StatelessServiceFactory factory, Duration timeout)
Asynchronously registers the specified StatelessServiceFactory for the specified service type, with the specified timeout and cancellationToken
Parameters:
Returns: