北京工业大学 网格计算 实验报告Word文件下载.docx

上传人:b****5 文档编号:20797078 上传时间:2023-01-25 格式:DOCX 页数:11 大小:86.13KB
下载 相关 举报
北京工业大学 网格计算 实验报告Word文件下载.docx_第1页
第1页 / 共11页
北京工业大学 网格计算 实验报告Word文件下载.docx_第2页
第2页 / 共11页
北京工业大学 网格计算 实验报告Word文件下载.docx_第3页
第3页 / 共11页
北京工业大学 网格计算 实验报告Word文件下载.docx_第4页
第4页 / 共11页
北京工业大学 网格计算 实验报告Word文件下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

北京工业大学 网格计算 实验报告Word文件下载.docx

《北京工业大学 网格计算 实验报告Word文件下载.docx》由会员分享,可在线阅读,更多相关《北京工业大学 网格计算 实验报告Word文件下载.docx(11页珍藏版)》请在冰豆网上搜索。

北京工业大学 网格计算 实验报告Word文件下载.docx

此处本应为25个服务,由于此为实验完成后截图,所以自定义服务(第二十六条)已部署。

2)服务部署

a.解压服务端与客户端源码到C盘根目录;

b.为MathService创建GAR文件。

在cmd下输入

globus-build-service.py-dC:

\gt4book-examples\org\globus\examples\services\core\first\impl-sC:

\gt4book-examples\schema\examples\MathService_instance

c.运行MathService例子。

globus-build-service.py

-dorg/globus/examples/services/core/first/

-sschema/examples/MathService_instance/Math.wsdl

做完以上几步后,应该得到如下结果:

1.生成GAR文件:

org_globus_examples_services_core_first.gar

2.在工作目录生成build和tmp两个文件夹,build中有生成的stubs源文件和class文件

d.使用GT4工具。

在cmd中输入:

globus-deploy-gar

C:

\gt4book-examples/org_globus_examples_services_core_first.gar

以部署服务,此步之后,就可以看到第26项服务了。

3)编译客户端

a.将Globus库写入CLASSPATH。

在cmd中运行脚本globus-devel-env.bat(注意:

此处应先进入globus-devel-env.bat的所在目录);

b.命令行编译

Javac-classpathC:

\gt4book-examples\build\stubs\classes;

%CLASSPATH%C:

\gt4book-examples\org\globus\examples\clients\MathService_instance\Client.java

即可编译客户端java脚本,在Eclipse中按照本组的给定算式编写java程序,然后再次编译,看是否有错。

编译通过后可以进入运行步骤。

4)运行

a.启动容器。

在cmd中输入globus-start-container–nosec;

b.启动客户端。

另起一个cmd窗口,java-classpath%CLASSPATH%;

c:

\gt4book-examples\build\stubs\classesorg.globus.examples.clients.MathService_instance.Clienthttp:

//127.0.0.1:

8080/wsrf/services/examples/core/first/MathService

即可看到程序运行结果。

二、实验环境

JavaJDK1.5

Eclipse

Tomcat服务器

Ant

Python

GT4JavaWSCore4.0.8

三、程序的逻辑框图

四、程序源代码(核心部分)

/*客户端代码

*/

packageorg.globus.examples.clients.MathService_instance;

importorg.apache.axis.message.addressing.Address;

importorg.apache.axis.message.addressing.EndpointReferenceType;

importorg.globus.examples.stubs.MathService_instance.GetValueRP;

importorg.globus.examples.stubs.MathService_instance.MathPortType;

importorg.globus.examples.stubs.MathService_instance.service.MathServiceAddressingLocator;

publicclassClient{

publicstaticvoidmain(String[]args){

MathServiceAddressingLocatorlocator=newMathServiceAddressingLocator();

try{

StringserviceURI=args[0];

//Createendpointreferencetoservice

EndpointReferenceTypeendpoint=newEndpointReferenceType();

endpoint.setAddress(newAddress(serviceURI));

//GetPortType

MathPortTypemath=locator.getMathPortTypePort(endpoint);

System.out.println("

初始值:

x="

+math.getValueRP(newGetValueRP()));

//输出x的初始值

//Performanaddition

math.add(10);

//进行加10操作

x=x+10"

);

//输出算式

Currentvalue:

x="

//输出x当前值

}catch(Exceptione){//异常处理

e.printStackTrace();

}

}

}

/*服务端代码

packageorg.globus.examples.services.core.first.impl;

importjava.rmi.RemoteException;

importorg.globus.examples.stubs.MathService_instance.AddResponse;

importorg.globus.examples.stubs.MathService_instance.SubtractResponse;

importorg.globus.wsrf.Resource;

importorg.globus.wsrf.ResourceProperties;

importorg.globus.wsrf.ResourceProperty;

importorg.globus.wsrf.ResourcePropertySet;

importorg.globus.wsrf.impl.ReflectionResourceProperty;

importorg.globus.wsrf.impl.SimpleResourcePropertySet;

publicclassMathServiceimplementsResource,ResourceProperties{

/*ResourcePropertyset*/

privateResourcePropertySetpropSet;

/*Resourceproperties*/

privateintvalue;

privateStringlastOp;

/*Constructor.InitializesRPs*/

publicMathService()throwsRemoteException{

/*CreateRPset*/

this.propSet=newSimpleResourcePropertySet(

MathConstants.RESOURCE_PROPERTIES);

/*InitializetheRP'

s*/

ResourcePropertyvalueRP=newReflectionResourceProperty(

MathConstants.RP_VALUE,"

Value"

this);

this.propSet.add(valueRP);

setValue(0);

//设定初值为0

ResourcePropertylastOpRP=newReflectionResourceProperty(

MathConstants.RP_LASTOP,"

LastOp"

this.propSet.add(lastOpRP);

setLastOp("

NONE"

//设定初始操作符为空

}catch(Exceptione){

thrownewRemoteException(e.getMessage(),e);

/*Get/SettersfortheRPs*/

publicintgetValue(){

returnvalue;

publicStringgetLastOp(){

returnlastOp;

publicsynchronizedvoidsetLastOp(StringlastOp){

this.lastOp=lastOp;

/*Remotely-accessibleoperations*/

publicsynchronizedAddResponseadd(inta)throwsRemoteException{

value+=a;

lastOp="

ADDITION"

;

returnnewAddResponse();

publicsynchronizedSubtractResponsesubtract(inta)throwsRemoteException{

value-=a;

SUBTRACTION"

returnnewSubtractResponse();

publicintgetValueRP(GetValueRPparams)throwsRemoteException{

/*RequiredbyinterfaceResourceProperties*/

publicResourcePropertySetgetResourcePropertySet(){

returnthis.propSet;

publicsynchronizedvoidsetValue(intvalue){

this.value=value;

publicsynchronizedAddResponseadd(inta)throwsRemoteException{//加运算

//修改末操作符为“+”

publicsynchronizedSubtractResponsesubtract(inta)throwsRemoteException{//减运算

//修改末操作符为“-”

/*从本代码可以看出中间结果的保存是由于设置运算结果等数据为静态变量

*ThisfileislicensedunderthetermsoftheGlobusToolkitPublicLicense

*v3,foundathttp:

//www.globus.org/toolkit/legal/4.0/license-v3.html.

*

*Thisnoticemustappearinredistributionsofthisfile,withorwithout

*modification.

importjavax.xml.namespace.QName;

publicinterfaceMathConstants{

publicstaticfinalStringNS="

http:

//www.globus.org/namespaces/examples/MathService_instance"

publicstaticfinalQNameRP_VALUE=newQName(NS,"

publicstaticfinalQNameRP_LASTOP=newQName(NS,"

publicstaticfinalQNameRESOURCE_PROPERTIES=newQName(NS,

"

MathResourceProperties"

五、实验数据、结果分析

本组的自定算式是计算x=x+10

程序的第一步是返回x的初值,紧接着进行x=x+10的操作,最后返回add后的当前x值。

紧接着再次运行了程序,可以看出初值更新为了40,说明这是一个可以保存中间结果的服务(是通过设置运算结果为静态变量实现的),之后的算术操作同前面。

六、总结

为其四周的网格实验课程结束了,从最开始的搭建实验环境,一步一步走到最后成功运行服务,我收获了很多。

记得一开始的时候,可以说是根本不明白整个实验的流程。

从最开始的环境变量配置就开始卡壳,由于有一个环境变量设置错误导致了测试失败,后来回头一个一个检查终于找到了错误,浪费了不少时间,不过这也对我后来起到了很好的警示作用,要更加的认真仔细进行实验。

在整个实验过程中,基本上就是按照老师给的指导ppt上的套路一步一步的向下做,其中做到编译客户端的时候打开globus-devel-env.bat的时候遇到了找不到文件的问题,后来在老师指导下明白了应该先用dos指令进入该文件所在的目录,然后才能运行该文件。

后来的几个类似的问题我们就自己仿照着解决了。

最终顺利完成了实验。

这次的课程让我们的实验能力有了很大的提升,积累了经验和方法。

虽然成功的完成了实验,但只能算是站在前人的肩膀上摘苹果,对于网格我们只能算是略懂皮毛。

实验结束了,但是我们还会学的更远!

最后,感谢陈老师在实验过程中对我们的关心和耐心指导!

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 文学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1