Export (0) Print
Expand All

Durable Session Client Template

The Cluster-SOA Debugger for Windows HPC 2008 R2 includes a template for creating a Durable Session Client. This type of client uses the DurableSession and BrokerClient objects to support reliable calculations and client interaction models such as file and recollect. The template includes references to the necessary HPC namespaces and the outline of the code that is used to create and start a durable session on a Windows HPC 2008 R2 cluster.

In this topic:

Creating a new Durable Session Client project

When you create a new project using the Durable Session Client template, a series of dialog boxes appear that prompt you to specify a cluster head node and to add a service reference. When you add a service reference to a project in Visual Studio, the WCF client objects (client proxies) are created automatically. To support asynchronous calls and the BrokerClient object, you must select the following advanced options for the service reference:

  • Generate asynchronous operations. This option generates methods such as BeginGetData and EndGetData in the resulting WCF client object.

  • Always generate message contracts. This option implements the GetDataRequest and GetDataResponse data types for the BrokerClient object.

After you provide this information, the following updates are made automatically to the solution:

  • The following updates are made to Program.cs:

    • A reference to your service is included in the using statements.

    • Your head node is specified in the schedulerName variable.

    • The interface for the service that you specified is used to create the broker client objects. (For example: (BrokerClient<IYourService> client = new BrokerClient<IYourService>(session, binding).)

  • The service contract name is updated in the client configuration file (app.config). In app.config, the first endpoint element defines the HPC SOA Debugging Endpoint. The contract attribute specifies the service contract name.

ImportantImportant
If you see any errors messages after closing the dialog boxes, or if you do not specify a service reference when you create the Durable Session Client project, you will need to make these updates manually.

The DurableSession and BrokerClient objects

The Windows HPC Pack 2008 R2 SDK includes support for creating reliable sessions and client interaction models such as file and recollect, batch, and shared session clients. These scenarios are supported by additions to the Microsoft.Hpc.Scheduler.Session namespace, including the BrokerClient class and the DurableSession class. Many of the new supported models do not require changes the service code, just to the client.

DurableSession supports reliable computations. When a DurableSession is created, request and response messages are persisted by the broker node so that in event of client or network failure, requests and responses are not lost. Clients can attach to a session with the same session ID to retrieve responses using the AttachSession() method.

The AttachSession() method is a non-blocking call that retrieves responses, but does not cause the broker node to release the responses (so they can be retrieved again in the case of failure). This allows you to attach to a crashed session to retrieve responses, or to restart a file and recollect session to retrieve responses.

BrokerClient supports decoupled sending and receiving of typed messages to and from a WCF service. The BrokerClient constructor wraps your WCF client (client proxy) to override standard call behavior and create a message-based proxy. In the standard WCF client, a single call sends and receives responses. In the BrokerClient, sending and receiving are separate calls.

Elements of the Durable Session Client template

The following table describes the elements of the Durable Session Client template:

 

Template element Purpose

Properties

AssemblyInfo.cs

Includes attributes that define information about your assembly.

Set information about your assembly (such as title and description) in this file.

References

Microsoft.Hpc.Scheduler.Session namespace

Microsoft.Hpc.Scheduler.Properties namespace

Microsoft.Hpc.Scheduler.Session: Includes classes that allow the client application to create and define an HPC session with multiple instances of a given service, bind the session to the client, and process the results from the service instances.

Microsoft.Hpc.Scheduler.Properties: Defines the enumerations and property identifiers that are used to submit and monitor jobs in a Windows HPC cluster.

See HPC Class Library.

Service References

When you include a service reference in your project, Visual Studio creates files that are required for the proxy class. A Durable Session Client project requires that the service reference is created with the following advanced options selected:

  • Generate asynchronous operations

  • Always generate message contracts

If the message contract is not generated, you will see an error indicating that the message contract can’t be found and that a placeholder file was created. (Client.cs)

app.config

Defines binding configuration settings for the client.

Specify the service contract name in this file.

app.config.TemplateForService.xml

This is a template for a service configuration file that defines binding configuration settings for the service. You can copy this template to your service library project to use instead of the default App.config file.

Specify the service name and the service contract name in this file. Optionally, adjust the timeout settings.

Client.cs

Provides a placeholder for the WCF client proxy object if you do not include a service reference or if the message contract can’t be found when adding the reference. For durable session clients, this file implements the GetDataRequest and GetDataResponse data types for the BrokerClient object.

You will need to replace the two occurrences of Client in the Program.cs code with your client proxy object.

Program.cs

Provides a template for the client code. The template includes placeholders for the name of the head node, the name of the service, and the WCF client object.

This file includes the code to perform the following tasks:

  • Specify a head node

  • Specify the service name

  • Create and start a session on the cluster

  • Store the session ID

  • Create a broker client instance and send requests

  • Create a new broker client instance that attaches to the same session to retrieve responses

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft