+ All Categories
Home > Documents > Step-by-Step Guide for Building, Deploying, and Running...

Step-by-Step Guide for Building, Deploying, and Running...

Date post: 08-Apr-2018
Category:
Upload: dangdung
View: 214 times
Download: 0 times
Share this document with a friend
16
Step-by-Step Guide for Building, Deploying, and Running SOA-based Applications in Windows HPC Server 2008 Beta 2 Microsoft Corporation Published: May 2008 Abstract This guide describes how to build, deploy, and run Service Oriented Application-based applications for Windows® HPC Server 2008 Beta 2. Using the Service Oriented Application (SOA) programming model, solution developers and architects can rapidly develop new HPC cluster-enabled interactive applications that enable new existing distributed computing scenarios. The developer experience of building, debugging, and deploying applications takes advantage of the productivity gains of the Windows Communication Foundation (WCF) programming model, which reduces the time needed to create solutions. Deployment, operations, and management of the applications and systems are simplified by using Windows HPC Server 2008.
Transcript

Step-by-Step Guide for Building, Deploying, and Running SOA-based Applications in Windows HPC Server 2008 Beta 2

Microsoft Corporation

Published: May 2008

Abstract This guide describes how to build, deploy, and run Service Oriented Application-based applications for Windows® HPC Server 2008 Beta 2. Using the Service Oriented Application (SOA) programming model, solution developers and architects can rapidly develop new HPC cluster-enabled interactive applications that enable new existing distributed computing scenarios. The developer experience of building, debugging, and deploying applications takes advantage of the productivity gains of the Windows Communication Foundation (WCF) programming model, which reduces the time needed to create solutions. Deployment, operations, and management of the applications and systems are simplified by using Windows HPC Server 2008.

Copyright This document supports a preliminary release of a software product that may be changed substantially prior to final commercial release, and is the confidential and proprietary information of Microsoft Corporation. It is disclosed pursuant to a non-disclosure agreement between the recipient and Microsoft. This document is provided for informational purposes only and Microsoft makes no warranties, either express or implied, in this document. Information in this document, including URL and other Internet Web site references, is subject to change without notice. The entire risk of the use or the results from the use of this document remains with the user. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 2008 Microsoft Corporation. All rights reserved.

Microsoft, Visual C#, Visual Studio, Windows, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

All other trademarks are property of their respective owners.

Contents Step-by-Step Guide for Building, Deploying, and Running SOA-based Applications in Windows

HPC Server 2008 Beta 2 .............................................................................................................. 4 Technology Review ...................................................................................................................... 4 Overview ...................................................................................................................................... 4 

Requirements for the Hello World Sample ...................................................................................... 4 

Setting up the lab environment ........................................................................................................ 5 Configure the head node to be a broker node ............................................................................. 5 

Steps for Building an SOA application ............................................................................................ 6 Step 1: Creating the Service ....................................................................................................... 6 Step 2: Deploying the Service ...................................................................................................... 8 Step 3: Creating the Client ........................................................................................................... 8 

Verifying Service Deployment ....................................................................................................... 13 

[This is prerelease documentation and is subject to change in future releases.]

Step-by-Step Guide for Building, Deploying, and Running SOA-based Applications in Windows HPC Server 2008 Beta 2

The following instructions are to be used in conjunction with the sample code found in the WCFBrokerSample.zip file in the Microsoft® HPC Pack 2008 SDK. The sample includes a simple Windows Communication Foundation (WCF) client and service project. These instructions guide you through the process of deploying and executing the client and service on Windows HPC Server 2008.

Technology Review Windows® HPC Server 2008 provides a platform for SOA-based applications. Using the Service Oriented Application (SOA) programming model, solution developers and architects can rapidly develop new high-performance computing (HPC) cluster-enabled interactive applications that enable new existing distributed computing scenarios. The developer experience of building, debugging, and deploying applications takes advantage of the productivity gains of the WCF programming model, which reduces the time needed to create solutions. Deployment, operations, and management of the applications and systems are simplified by using Windows HPC Server 2008.

Overview Using the Hello World sample (WCFBrokersample.zip) illustrates that the development platform provides an easy-to-use API and that Microsoft® Visual Studio® development system provides easy-to-use WCF service templates and service referencing utilities. These features enable developers to quickly prototype, debug, and unit-test applications.

Requirements for the Hello World Sample The software requirements for building the Hello World sample are:

• Windows HPC Server 2008 Beta 2

This sample only works with Windows HPC Server 2008 Beta 2. Before building and deploying this sample, install Windows HPC Server 2008 Beta 2. To obtain this software, join the Windows HPC Server 2008 beta program at http://connect.microsoft.com.

• Visual Studio

After you install the HPC Pack 2008 for Windows HPC Server 2008 Beta 2, also install either Visual Studio 2005 or Visual Studio 2008 on your development workstation. For convenience, you can use the head node of the cluster for development. To obtain Visual Studio 2008, download either the Professional Edition or the Enterprise Suite at http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx.

[This is prerelease documentation and is subject to change in future releases.]

Setting up the lab environment

Configure the head node to be a broker node The head node must have the WCFBrokerNodes node role. To verify that this role is enabled, launch the admin console. The router node must be a member of the WCFBrokerNodes node group, as shown below:

If the broker node role is not enabled, the following procedure describes how to configure a WCF broker node.

To configure the head node to be a broker node 1. In the admin console, click Node Management in the navigation pane.

2. In the tree view, navigate to Nodes, then By Group and Head Nodes.

3. In the center results pane, click the head node that you want to configure as a WCFBrokerNode.

4. In the Actions pane, click Take offline.

5. In the Take Offline Node dialog box, click Yes.

6. Verify in the central results pane that the state of the node changed to Offline.

7. In the Actions pane, click Change Role.

8. In the Change Additional Role dialog box, choose Service Broker Node and then click OK.

9. In the Action pane, click Take online.

[This is prerelease documentation and is subject to change in future releases.]

10. Verify that WCFBrokerNodes appears in the Groups column.

Now you are ready to work with the sample.

Steps for Building an SOA application Building an SOA application using the SOA programming model consists of three steps:

• Step 1. Creating the service.

• Step 2. Deploying the service to a cluster.

• Step 3. Creating a client application.

Step 1: Creating the Service To create the service

1. On the File menu in Visual Studio 2008, point to New and click Project. 2. Under Project types in the New Project dialog box, click WCF under Visual C#, then click WCF

Service Library under Templates.

3. In the Name box, type EchoService, then click OK.

4. Under EchoService in the Project Explorer pane, right-click References and click Add Reference.

5. On the .NET tab of the Add Reference dialog box, click System.ServiceModel and click OK.

or

On the Browse tab of the Add Reference dialog box, navigate to the %windir%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation folder in the Look in list, then click System.ServiceModel.dll and click OK. Use this alternative if System.ServiceModel does not appear on the .NET tab.

This reference is required for writing the WCF Service code.

6. In the Solution Explorer pane, right-click Service1.cs and click Rename, then change the name of the file to EchoService.cs. Click Yes in the dialog box that prompts you to rename all references.

7. Right-click IService1.cs and click Rename, then change the name of the file to IEchoService.cs. Click Yes in the dialog box that prompts you to rename all references.

8. Double-click IEchoService.cs, then replace all of the code on the IEchoService.cs tab with the following code:

using System;

using System.Collections.Generic;

using System.Text;

using System.ServiceModel;

namespace EchoServiceLib

{

[This is prerelease documentation and is subject to change in future releases.]

[ServiceContract]

public interface IEchoService

{

[OperationContract]

string Echo(string input);

}

}

9. Double-click EchoService.cs, then replace all of the code on the EchoService.cs tab with the following code:

using System;

using System.Collections.Generic;

using System.Text;

using System.Diagnostics;

using System.ServiceModel;

namespace EchoServiceLib

{

[ServiceBehavior(IncludeExceptionDetailInFaults=true)]

public class EchoSvc : IEchoService

{

//static int cnt = 0;

#region IEchoService Members

public string Echo(string input)

{

Debug.WriteLine(input);

Console.WriteLine(input);

return Environment.MachineName + ":" + input;

}

#endregion

}

}

[This is prerelease documentation and is subject to change in future releases.]

10. On the Build menu, click Build Solution. The build creates a file named EchoService.dll in the Visual Studio 2008\Projects\EchoService\EchoService\bin\[Debug|Release] folder.

Step 2: Deploying the Service To deploy the service

1. Copy the EchoService.dll file to the %SystemDrive%\Services folder on all compute nodes. Create the folder if it does not already exist.

2. Create a file named EchoService.config file on each node in the cluster with the content in the following example in the %CCP_HOME%\ServiceRegistration folder to register the service DLL. The default location of this folder is: C:\Program Files\Microsoft HPC Pack\ServiceRegistration.

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

<!--Register service's custom configruation sections and group-->

<sectionGroup name="microsoft.Hpc.Session.ServiceRegistration"

type="Microsoft.Hpc.Scheduler.Session.Configuration.ServiceRegistration,

Microsoft.Hpc.Scheduler.Session, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35">

<section name="service"

type="Microsoft.Hpc.Scheduler.Session.Configuration.ServiceConfiguration,

Microsoft.Hpc.Scheduler.Session, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"

allowDefinition="Everywhere"

allowExeDefinition="MachineToApplication" />

</sectionGroup>

</configSections>

<microsoft.Hpc.Session.ServiceRegistration>

<service assembly="c:\Services\EchoServiceLib.dll"

contract="EchoServiceLib.IEchoService"

type="EchoServiceLib.EchoService" />

</microsoft.Hpc.Session.ServiceRegistration>

</configuration>

For information about how to verify that deployment succeeded, see “Verifying Service Deployment” later in this guide.

Step 3: Creating the Client To create the client, you perform the following procedures:

[This is prerelease documentation and is subject to change in future releases.]

• Create a client proxy.

• Create and configure a console application project for the client.

• Add code to the project, then build and run the application.

To create a client proxy 1. On the Start menu on your development workstation, point to All Programs, then Microsoft Visual

Studio 2008 and Visual Studio Tools and click Visual Studio 2008 Command Prompt. 2. Use the cd command to navigate to the folder that contains the EchoService.dll file. By default, this

folder is C:\Users\user_name\Documents\Visual Studio 2008\Projects\EchoService\EchoService\bin\[Debug|Release].

3. Run the following command to generate the WSDL and XSD files for the service.

svcutil EchoService.dll

4. Run the following command to create the EchoClientProxy.cs file:

svcutil *.wsdl *.xsd /async /language:C# /out:EchoClientProxy.cs

To create and configure a console application project for the client 1. On the File menu in Visual Studio 2008, point to New and click Project. 2. Under Project types in the New Project dialog box, click Windows under Visual C#, then click

Console Application under Templates.

3. In the Name box, type EchoClient, then click OK.

4. Under EchoClient in the Project Explorer pane, right-click References and click Add Reference.

5. On the .NET tab of the Add Reference dialog box, click System.ServiceModel and click OK.

or

On the Browse tab of the Add Reference dialog box, navigate to the %windir%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation folder in the Look in list, then click System.ServiceModel.dll and click OK. Use this alternative if System.ServiceModel does not appear on the .NET tab.

This reference is required for writing the WCF Service code.

6. Under EchoClient in the Project Explorer pane, right-click References and click Add Reference.

7. On the Browse tab of the Add Reference dialog box, navigate to the %CCP_SDK%\bin folder in the Look in list, then select Microsoft.Hpc.Scheduler.dll, Microsoft.Scheduler.Properties.dll, and Microsoft.Hpc.Scheduler.Session.dll and click OK.

To add code to the project, then build and run the application 1. In the Project Explorer pane, right-click EchoClient, then point to Add and click Existing Item.

2. In the Add Existing Item dialog box, browse to the folder that contains the EchoClientProxy.cs file, click the file and then click Add.

3. In the Solution Explorer pane, double-click Program.cs, then replace all of the code on the Program.cs tab with the following code:

using System;

using System.Collections.Generic;

[This is prerelease documentation and is subject to change in future releases.]

using System.Text;

using System.ServiceModel;

using System.Threading;

using Microsoft.Hpc.Scheduler.Session;

namespace EchoClient

{

class Program

{

static void Main(string[] args)

{

string scheduler = "localhost";

string serviceName = "EchoService";

if (args.Length > 0)

{

scheduler = args[0];

if (args.Length > 1)

{

serviceName = args[1];

}

}

// Create a session object that specifies the head node

// to which to connect

//and the name of the WCF service to use.

// This example uses the default start information for a

// session.

SessionStartInfo info = new SessionStartInfo(scheduler, serviceName);

info.ResourceUnitType =

Microsoft.Hpc.Scheduler.Properties.JobUnitType.Node;

info.MinimumUnits = 1;

info.MaximumUnits = 4;

Console.WriteLine("Creating a session...");

// Create the session by calling the factory method

[This is prerelease documentation and is subject to change in future releases.]

using (Session session = Session.CreateSession(info))

{

Console.WriteLine("Session's Endpoint Reference:{0}",

session.EndpointReference.ToString());

// Binds session to the client proxy using NetTcp

// binding (specify only NetTcp binding). The

// security mode must be Transport and you cannot

// enable reliable sessions.

EchoServiceClient client = new EchoServiceClient(new

NetTcpBinding(SecurityMode.Transport, false), session.EndpointReference);

AsyncResultCount = 100;

for (int i = 0; i < 100; i++)

// EchoCallBack is defined in EchoClientProxy.cs.

{

// This call will not block,

// as results becomes available

// the EchoCallBack method will be invoked

client.BeginEcho("hello world", EchoCallback, new RequestState(client,

i));

}

AsyncResultsDone.WaitOne();

client.Close();

Console.WriteLine("Please enter any key to continue...");

Console.ReadLine();

}

}

static int AsyncResultCount = 0;

static AutoResetEvent AsyncResultsDone = new AutoResetEvent(false);

// Encapsulates the context of the function callback

class RequestState

[This is prerelease documentation and is subject to change in future releases.]

{

int input;

EchoServiceClient client;

public RequestState(EchoServiceClient client, int input)

{

this.client = client;

this.input = input;

}

public int Input

{

get { return input; }

}

public string GetResult(IAsyncResult result)

{

return client.EndEcho(result);

}

}

static void EchoCallback(IAsyncResult result)

{

RequestState state = result.AsyncState as RequestState;

Console.WriteLine("Response({0}) = {1}", state.Input, state.GetResult(result));

if (Interlocked.Decrement(ref AsyncResultCount) <= 0)

{

AsyncResultsDone.Set();

}

}

}

}

4. On the Build menu, click Build Solution to compile the client program.

[This is prerelease documentation and is subject to change in future releases.]

5. Press F5 to run the client program.

The following shows the output of the client program.

Verifying Service Deployment To ensure that services are deployed correctly, use the diagnostic tools on the head node.

To verify deployment 1. Open the Administration Console, and click Diagnostics in the left pane.

2. Click Tests in the left pane, then click SOA Service Configurations Report in the list of tests in the center pane.

[This is prerelease documentation and is subject to change in future releases.]

The following shows the list of diagnostic tests.

3. In the Actions pane, click Run.

4. In the Run Diagnostics dialog box, click Nodes in this group, then choose ComputeNodes and click Run.

The following shows the Run Diagnostics dialog box.

 

[This is prerelease documentation and is subject to change in future releases.]

5. Under Test Results in the left pane to see that the test is underway.

The following shows how the list of running tests appears.

6. In the left pane, click Complete to view the list of completed reports.

7. In the center pane, double-click the report you want to view. In the summary section, look for EchoService. It should be deployed on all of the nodes, and value in the No. of Nodes column on the far right should be All.

[This is prerelease documentation and is subject to change in future releases.]

The following shows an example of the SOA Service Configurations report.

 


Recommended