演習 1~6 Globus Toolkit Version 4 (Java WS Core) 演習 : WS-Resource の生成と機能拡張
目標 :GT4 Java Core WSRF 基本仕様のサポート確認 サーバー側の実装方法 サービス 各種設定ファイル ( の実装方法 ) 最低限 WSRF の標準的な機能は GT4 に含まれる標準で利用可能 GT4 標準の利用方法 wsrf-get-property wsrf-update-property wsrf-destroy wsrf-set-termination-time
概要 Grid Computing 0.Borja Sotomayor, The Globus Toolkit 4 Programmer s Tutorial が基本 http://gdp.globus.org/gt4-tutorial/ Chapter 5. Multiple Resources に修正を加え その効果を逐次確認する 1.WS-Core の導入 2. 標準的な WS-Resource パターンの確認 サービス及びの構築 デプロイ アクセス確認 3. プロパティに対するアクセス手段の追加 ( オペレーション プロバイダの活用 ) 実装は修正せず WSDL, WSDD ファイルの変更のみで実現 4. プロパティのコードにおける表現方法を変更 ( サービス / 実装の変更 ) サービス / の実装のみを変更 5.WS-ResorceLifeTime への対応 :Immediate Destruction WSDL, WSDD ファイルの変更のみで実現 6. WS-ResorceLifeTime への対応 :Scheduled Destruction WSDL/WSDD 実装の修正 サービス実装は変更なし オプション :JNDI のデプロイファイルの修正 ( 破棄時刻をより正確にするため )
WS-Resource の拡張 ( 本日の演習 ) カスタム wsrf-getproperty wsrf-updateproperty wsrfdestroy wsrf-setterminationtime WS-Resource Custom method (Get Property) WS-Resource Custom method Get Property Set Property WS-Resource Custom method Get Property Set Property Immediate Destruction WS-Resource Custom method Get Property Set Property Immediate Destruction Scheduled Destruction 2 3,4 5 6
2. 標準的なWS-Resourceパターンの確認 ( 主要ファイルのみ )
( 無修正で使用 ) MathFactoryService を呼び出し End Point Reference (EPR) を取得する WS-Resource が生成される 演習を通じて 修正無しで使用する // Get factory porttype factoryepr = new EndpointReferenceType(); factoryepr.setaddress(new Address(factoryURI)); mathfactory = factorylocator.getfactoryporttypeport(factoryepr); // Create resource and get endpoint reference of WS-Resource CreateResourceResponse createresponse = mathfactory.createresource(new CreateResource()); instanceepr = createresponse.getendpointreference(); // Write endpoint reference to file..
( 無修正で使用 ) EPR で示された WS-Resource (MathService + MathResource) に加算を依頼 結果を受け取る 演習を通じて 修正無しで使用する // Get endpoint reference of WS-Resource from file FileInputStream fis = new FileInputStream(eprFile); instanceepr = (EndpointReferenceType) ObjectDeserializer.deserialize( new InputSource(fis),EndpointReferenceType.class); fis.close(); // Get PortType MathPortType math = instancelocator.getmathporttypeport(instanceepr); // Perform addition math.add(value);..
その他のファイル ( 無修正で使用 ) ( 図中省略 ) 名前空間の扱いを簡易にするための補助ファイル ( 図中省略 ) ホーム ファクトリー サービス ctx = ResourceContext.getResourceContext(); home = (MathResourceHome) ctx.getresourcehome(); key = home.create(); String instanceservice = (String) MessageContext.getCurrentContext().getService().getOption("instance"); String instanceuri = baseurl.tostring() + instanceservice; epr = AddressingUtils.createEndpointReference(instanceURI, key);
( 修正あり ) WS-Resourceを形成するサービスの実装 プロパティの実装方法変更にあわせ 演習 3で修正 簡便な方法から よりWSRFの特徴が見える方法へ resource = ResourceContext.getResourceContext().getResource(); MathResource mathresource = (MathResource) resource; mathresource.setvalue(mathresource.getvalue() + a); // 初期状態 mathresource.setlastop("addition"); ResourceProperty valuerp = mathresource // 修正後.getResourcePropertySet().get(MathQNames.RP_VALUE); Integer value = (Integer) valuerp.get(0); value = new Integer(value.intValue()+a); valuerp.set(0, value);
(1, 修正あり ) WS-Resource を形成するの実装 演習 3 5 で修正 演習 5 まで終了したファイルから抜粋 public class MathResource implements Resource, ResourceIdentifier, ResourceProperties, ResourceLifetime { private Calendar terminationtime; public Object initialize() throws Exception { this.key = new Integer(hashCode()); this.propset = new SimpleResourcePropertySet( MathQNames.RESOURCE_PROPERTIES); valuerp = new SimpleResourceProperty(MathQNames.RP_VALUE); valuerp.add (new Integer(0)); this.propset.add(valuerp); return key; }
(2, 修正あり ) /* Required by interface ResourceLifetime */ public Calendar getcurrenttime() { return Calendar.getInstance(); } public Calendar getterminationtime() { return this.terminationtime; } public void setterminationtime(calendar terminationtime) { this.terminationtime=terminationtime; } インターフェース Web サービス } /* Required by interface ResourceProperties */ public ResourcePropertySet getresourcepropertyset() { return this.propset; } /* Required by interface ResourceIdentifier */ public Object getid() { return this.key; }
( 修正あり ) インターフェースを記述 そのままデプロイされるわけではない インター 全部を書かなくても良い フェースWeb サービス WSDL プリプロセッサー (GT が提供 ) 演習 2,4,5 で修正
( 修正あり ) デプロイの構成を行う サービスのURI 使用するクラスの指定 WSDLファイルの指定 GT4のツールを使用する場合は 後ろに _serviceを追加した形で指定する オペレーション プロバイダの指定 演習 2,4,5 で修正 <!-- Instance service --> <service name="examples/core/factory/mathservice" provider="handler" use="literal style="document"> <parameter name="classname value="org.globus.examples.services.core.factory.impl.mathservice"/> <wsdlfile>share/schema/examples/mathservice_instance/math_service.wsdl</wsdlfile> <parameter name="providers" value="getrpprovider SetRPProvider DestroyProvider SetTerminationTimeProvider SubscribeProvider GetCurrentMessageProvider"/> </service> * 注 : このリストは WS-Notification 対応を含みます
その他の設定ファイル ( 修正なし ) ファクトリーサービスのインターフェースを記述 ( 図中省略 修正あり なしにする ) ホームに関連 演習 5で修正 修正しなくても動作するが 破棄の検知に時間がかかる
Grid Computing WS-Resource の End Point Reference を示すテキストファイル ClientCreate によって生成される 他のに使用される <ns1:mathresourcereference xsi:type="ns2:endpointreferencetype" xmlns:ns1="http://www.globus.org/namespaces/examples/core/mathservice_instance" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:ns2="http://schemas.xmlsoap.org/ws/2004/03/addressing"> <ns2:address xsi:type="ns2:attributeduri"> http://192.168.1.1:8080/wsrf/services/examples/core/factory/mathservice </ns2:address> <ns2:referenceproperties xsi:type="ns2:referencepropertiestype"> <ns1:mathresourcekey>23578083</ns1:mathresourcekey> </ns2:referenceproperties> <ns2:referenceparameters xsi:type="ns2:referenceparameterstype"/> </ns1:mathresourcereference> インターフェース Web サービス
インターGrid Computing in.xml 演習 2 で使用 wsrf-update-property コマンドの入力ファイル in.xml フェースWeb サービス <?xml version="1.0" encoding="utf-8"?> <doc> <ns1:lastop xmlns:ns1="http://www.globus.org/namespaces/examples/core/mathservice_instance"> WSRF_UPDATE_PROPERTY </ns1:lastop> </doc>
参考 :globus-build-service チュートリアルに含まれているが 独立したプロジェクトとしても公開されている (GT4 標準添付ではない ) http://gsbt.sourceforge.net/content/view/14/31/ GT4 を用いた WSRF Web サービスの構築を容易にする 特定のディレクトリ構造に従ってファイルを用意する事が必要 関連ファイル globus-build-service.py build.mappings build.xml C: ws-core-4.0.2 share globus_wsrf_tools build-stubs.xml flatten, generatebindings, generatestubs, mergepackagemapping,.. C: ws-core-4.0.2 share globus_wsrf_common build-packages.xml makegar, deploygar, undeploygar,.. namespace2package.mappings
3. プロパティに対するアクセス手段の追加 (wsrf-get-property) (wsrf-update-property) in.xml
4. プロパティの表現方法を変更 (wsrf-get-property) (wsrf-update-property) in.xml
インターフェースGrid Computing 5.WS-ResorceLifeTime への対応 :Immediate Destruction Web サービス (wsrf-get-property) (wsrf-update-property) (wsrf-destroy) in.xml
インターフェースGrid Computing 6.WS-ResorceLifeTime への対応 :Scheduled Destruction Web サービス (wsrf-get-property) (wsrf-update-property) (wsrf-destroy) (wsrf-set-termination-time) in.xml