Working with the Web Service Interface
Windows HPC Server 2008 R2 with Service Pack 2 (SP2) provides access to the HPC Job Scheduler Service by using an HTTP web service that is based on the representational state transfer (REST) model. You can use this REST API to create client applications that users can use to define, submit, modify, list, view, requeue, and cancel jobs.
Windows HPC Server 2008 R2 with Service Pack 3(SP3) expands the HTTP web service to provide additional operations that provide information about nodes, node groups, and the cluster name. Windows HPC Server 2008 R2 with SP3 also provides operations that allow you to create and manage SOA sessions, and to send SOA requests and receive SOA responses for these sessions. The SOA operations that are available only when the REST web service is hosted in Windows Azure. All other operations are available either when the REST web service is hosted on an on-premise cluster or when the REST web service is hosted in Windows Azure.
You can use the REST API in many programming languages to create client applications, including programming languages that the .NET and COM APIs for Windows HPC Server do not support. You can also use to the REST API to create client applications that users on many operating systems can access, including operating systems that are not Windows-based.
Installing and Configuring the REST API
The web service is included in the HPC Pack web features installation package.
To install the HPC web features
- In Windows Explorer on the head node of your HPC cluster, navigate to the Setup folder on the installation media for the Microsoft HPC Pack 2008 R2 with SP2, or open the folder that you extracted from the download if you downloaded the SP2 update from the Microsoft Download Center.
- Double-click HpcWebComponents.msi.
- Follow the instructions in the Microsoft HPC Pack 2008 R2 Web Components Setup wizard.
You can use the Set-HPCWebComponents.ps1 script to configure the REST API after you install the REST API. For example, you can use the script to change the port or the method to authenticate client credentials that the REST API uses. This script is located in the %CCP_HOME%\bin folder on the head node after you install the HPC web features.
The following example shows the syntax for the Set-HPCWebComponents.ps1 script.
Set-HPCWebComponent.ps1 -Service service_name -enable -Certificate thumbprint_value [-Port port_number] [-AuthenticationMethod method_name]
Set-HPCWebComponent.ps1 -Service service_name -disable
The following table describes the parameters for the Set-HPCWebComponents.ps1 script.
| Parameter | Description |
|---|---|
| Service |
Required. Specifies the name of the web component that you want to configure. Specify REST to configure the REST API, or specify Portal to specify the web portal page. |
| enable |
Turns on the specified component. |
| disable |
Turns off the specified component. |
| Certificate |
Specifies the value of the Thumbprint property for the Secure Sockets Layer (SSL) certificate that you want to use to secure the web service. |
| Port |
The port on which you want to open the service. The default port is 443. |
| AuthenticationMethod |
The authentication method that you want to use to authenticate the credentials that the client application provides. The possible values are Basic and NTLM. The default authentication method is Basic. |
The following example turns on the REST web service for port 8000 with NTLM authentication.
Set-HPCWebComponents -Service REST -enable -Certificate 33CE10B55FE9A657815C3B19791340E375B7DF7C -AuthenticationMethod NTLM -Port 8000
The following example turns off the REST web service.
Set-HPCWebComponents.ps1 -Service REST -disable
Operations in the REST API
The HPC REST API defines a number of operations that you can perform, including the information that is expected in the HTTP requests that you send to the HPC REST web service and that is provided in the HTTP responses that you receive in return as part of each operation.
Note
The HPC REST API does not define the manner in which you create and send these HTTP requests and process the HTTP responses. The approach you can use to work with the HTTP requests and responses varies depending on the programming language that you use, and can also vary depending on the libraries or other tools that you choose to install to work with HTTP requests and responses in your programming language of choice. Additional information about working with the HTTP requests and responses is beyond the scope of this documentation. For an example of how to HTTP requests and responses for operations in the HPC REST API, see Creating and Submitting Jobs by Using the REST API in Windows HPC Server 2008 R2. (http://social.technet.microsoft.com/wiki/contents/articles/7737.creating-and-submitting-jobs-by-using-the-rest-api-in-windows-hpc-server-2008-r2.aspx)
The following table shows the operations that are available in the REST API both when the REST web service is hosted in an on-premise cluster, and when the REST web service is hosted in Windows Azure.
| Operation | Description |
|---|---|
| Add Task |
Adds a task to a job. |
| Cancel Job |
Cancels the specified job. |
| Cancel Subtask |
Cancels the specified subtask. |
| Cancel Task |
Cancels the specified task. |
| Create Job |
Creates a new job on the HPC cluster, for which the specified properties have the specified values. |
| Create Job From XML |
Creates a new job on the HPC cluster by using the information in the specified job XML. |
| Get Clusters |
Gets the name of the cluster that hosts the instance of the REST web service. Supported beginning with Windows HPC Server 2008 R2 with SP3. |
| Get Job |
Gets information about the specified job. |
| Get Job Custom Properties |
Gets the values of the specified custom properties for the job, or the values of all of the properties if none are specified. |
| Get Job Environment Variables |
Gets the values of the specified environment variables for the job, or the values of all of the environment variables if none are specified. |
| Get Job List |
Gets the values of the specified properties for all jobs with specified owner. If no owner is specified, gets values for the properties of all of the jobs for the HPC cluster. |
| Get Job Templates |
Gets a list of the names of the job templates that are available on the HPC cluster. |
| Get Node |
Gets the values of all of the properties for the specified node. Supported beginning with Windows HPC Server 2008 R2 with SP3. |
| Get Node Group List |
Gets the names and descriptions for all of the node groups for the HPC cluster. Supported beginning with Windows HPC Server 2008 R2 with SP3. |
| Get Node Group Members |
Gets the list of the nodes that belong to the specified node group. Supported beginning with Windows HPC Server 2008 R2 with SP3. |
| Get Node List |
Gets the values of the specified properties for all of the nodes in an HPC cluster. Supported beginning with Windows HPC Server 2008 R2 with SP3. |
| Get Subtask |
Gets the values of the specified properties for the specified subtask, or the values of all of the properties if no properties are specified. |
| Get Task |
Gets the values of the specified properties for the specified task, or the values of all of the properties if no properties are specified. |
| Get Task Custom Properties |
Gets the values of the specified custom properties for the task, or the values of all of the properties if none are specified. |
| Get Task Environment Variables |
Gets the values of the specified environment variables for the task, or the values of all of the environment variables if none are specified. |
| Get Task List |
Gets the values of the properties for all of the tasks in the specified job. |
| Get Version |
Gets the version of Windows HPC Server that is installed on the HPC cluster that hosts the web service. |
| Requeue Job |
Resubmits the specified job to the queue. |
| Requeue Subtask |
Moves a failed, canceled, or queued subtask to the configuring state so that the subtask can be queued again when the job is resubmitted. |
| Requeue Task |
Moves a failed, canceled, or queued task to the configuring state so that the task can be queued again when the job is resubmitted. |
| Set Job Custom Properties |
Sets the values of custom properties for a job. |
| Set Job Environment Variables |
Sets the value of one or more environment variables for a job. |
| Set Job Properties |
Sets the values for the properties of the specified job. |
| Set Subtask Properties |
Sets the values of properties for the task that contains that specified subtask. |
| Set Task Custom Properties |
Sets the values of custom properties for a task. |
| Set Task Environment Variables |
Sets the value of one or more environment variables for a task. |
| Set Task Properties |
Sets the values of properties for a task in a job. |
| Submit Job |
Submits a job to the HPC Job Scheduler Service so that the HPC Job Scheduler Service can add the job to the queue of jobs to run. |
The following table shows the operations that are available only when the REST web service is hosted in Windows Azure. All of the operations are supported starting with Windows HPC Server 2008 R2 with SP3.
| Operation | Description |
|---|---|
| Attach to Session |
Connects to an existing SOA session. |
| Close Session |
Closes a SOA session, which ends the job for the session and deletes the response messages. |
| Create Session |
Creates a new service-oriented architecture (SOA) session with the specified configuration information. |
| Delete Requests |
Deletes a batch of SOA requests that you previously sent. |
| Get Responses |
Gets the responses that the service-oriented architecture (SOA) service returned for the SOA requests in the specified batch. |
| Get Request Status |
Gets the status of a batch of SOA requests. |
| Indicate the End of Requests |
Indicates that you are finish sending SOA requests and that the broker should commit all requests. |
| Send Requests |
Sends a batch of SOA requests to the SOA service that you specified when you created the session. |
Getting Sample Programs that use the REST API
The SDK code samples for include sample client applications that use the REST API.
The code samples for Windows HPC Server 2008 R2 with SP2 include sample client applications in C# and Python that use the operations related to jobs and tasks. The code samples for Windows HPC Server 2008 R2 with SP3 include updated versions of these C# and Python applications, and additional sample client applications in C and Java that use the SOA operations.
You can download the SDK code samples for Windows HPC Server 2008 R2 with SP2 by downloading the HPC2008R2.SampleCode.zip file from the HPC Pack 2008 R2 SDK with Service Pack 2 download page (http://www.microsoft.com/download/en/details.aspx?id=26645). After you extract the files, the REST API examples are in the HPC2008R2.SampleCode\Scheduler\REST folder.
For Windows HPC Server 2008 R2 with SP2, the C# example requires that you install the WCF REST Starter Kit Preview 2. For information about how to download the WCF REST Starter Kit Preview 2, see http://aspnet.codeplex.com/releases/view/24644.
You can download the SDK code samples for Windows HPC Server 2008 R2 with SP3 by downloading the HPC2008R2.SampleCode.zip file from the HPC Pack 2008 R2 SDK with Service Pack 3 download page (http://www.microsoft.com/download/en/details.aspx?id=28016). After you extract the files, the C# and Python examples are in the HPC2008R2.SampleCode\Scheduler\REST folder. The C example is in the HPC2008R2.SampleCode\SOA\CPP\SoaWebApiClient folder. The Java example is in the HPC2008R2.SampleCode\SOA\Java\SoaWebApiClient folder.
For Windows HPC Server 2008 R2 with SP3, the C# example no longer requires that you install the WCF REST Starter Kit Preview 2. The C example requires the CURL and json-c libraries. For information about these libraries, see http://curl.haxx.se and http://oss.metaparadigm.com/json-c.
Build date: 7/27/2012