Partager via


FabricRuntime Class

  • java.lang.Object
    • AutoCloseable
      • system.fabric.FabricRuntime

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.

FabricRuntime create()

Creates the system.fabric.FabricRuntime object.

CompletableFuture<FabricRuntime> createAsync(Duration timeout)

Creates the system.fabric.FabricRuntime object asynchronously with the specified timeout parameter.

CompletableFuture<FabricRuntime> 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.

FabricCodePackageActivationContext getActivationContext()

Retrieves the current system.fabric.FabricRuntime's CodePackageActivationContext.

CompletableFuture<FabricCodePackageActivationContext> getActivationContextAsync(Duration timeout)

Retrieves the current system.fabric.FabricRuntime’s CodePackageActivationContext asynchronously with the specified parameter.

NodeContext getNodeContext()

Gets the Node Context object that contains information about Fabric Node.

CompletableFuture<NodeContext> 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:

A newly created system.fabric.FabricRuntime object.

createAsync

public static CompletableFuture createAsync(Duration timeout)

Creates the system.fabric.FabricRuntime object asynchronously with the specified timeout parameter.

Parameters:

timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

Returns:

The task representing the asynchronous operation.

createAsync

public static CompletableFuture 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.

Parameters:

fabricExitCallback - The Action to be executed when the runtime exits or terminates.
timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

Returns:

The task representing the asynchronous operation.

getActivationContext

public static FabricCodePackageActivationContext getActivationContext()

Retrieves the current system.fabric.FabricRuntime's CodePackageActivationContext.

Returns:

The activation context.

getActivationContextAsync

public static CompletableFuture getActivationContextAsync(Duration timeout)

Retrieves the current system.fabric.FabricRuntime’s CodePackageActivationContext asynchronously with the specified parameter.

Parameters:

timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException

Returns:

The task representing the asynchronous operation.

getNodeContext

public static NodeContext getNodeContext()

Gets the Node Context object that contains information about Fabric Node.

Returns:

The node context.

getNodeContextAsync

public static CompletableFuture getNodeContextAsync(Duration timeout)

Gets Node Context from Fabric Node asynchronously with timeout and cancellation token.

Parameters:

timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException

Returns:

The task representing the asynchronous operation.

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:

serviceTypeName - The type name of the service type (as a string). This should match the type of the service group type as specified in the manifests and/or the CreateService command.
serviceTypeImplementation - The qualified service Type that implements the specified serviceTypeName.

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:

serviceTypeName - The type name of the service type (as a string). This should match the type of the service group type as specified in the manifests and/or the CreateService command.
serviceTypeImplementation - The qualified service Type that implements the specified serviceTypeName.
timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

Returns:

The task representing the asynchronous operation.

registerStatefulServiceFactory

public void registerStatefulServiceFactory(String serviceTypeName, StatefulServiceFactory factory)

Registers the specified StatefulServiceFactory for the specified service type.

Parameters:

serviceTypeName - The type name of the service type (as a string). This should match the type of the service group type as specified in the manifests and/or the CreateService command.
factory - The StatefulServiceFactory which can create the specified service type.

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:

serviceTypeName - The type name of the service type (as a string). This should match the type of the service group type as specified in the manifests and/or the CreateService command.
factory - The StatefulServiceFactory which can create the specified service type.
timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

Returns:

The representing the asynchronous operation.

registerStatelessServiceFactory

public void registerStatelessServiceFactory(String serviceTypeName, StatelessServiceFactory factory)

Registers the specified StatelessServiceFactory for the specified service type.

Parameters:

serviceTypeName - The type name of the service type (as a string). This should match the type of the service group type as specified in the manifests and/or the CreateService command.
factory - The StatelessServiceFactory which can create the specified service type.

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:

serviceTypeName - The type name of the service type (as a string). This should match the type of the service group type as specified in the manifests and/or the CreateService command.
factory - The StatelessServiceFactory which can create the specified service type.
timeout - The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.

Returns:

The task representing the asynchronous operation.

Applies to