CÔNG NGHỆ GRID COMPUTING VÀ ỨNG DỤNG THỬ NGHIỆM TRONG BÀI TOÁN QUẢN TRỊ MẠNG - 10 - Pdf 20



Phụ lục
- 193 -
<xsd:sequence>
<xsd:element name="value" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="addResponse">
<xsd:complexType/>
</xsd:element>

</xsd:schema>
</types>

&lt! Messages >

&lt! PortType >

</definitions>

Ở đây định nghĩa các kiểu của các thành phần add và addResponse.


à
i

đ


t
tc
c
á
á
c
cc
c
h
h


c
c


aG
G
r
r
i
i
d
dS
S
e
e
r
r
v
v
i
i
c
c
e
eC

à
i

đ


t
tO
O
p
p
e
e
r
r
a
a
t
t
i
i
o
o
n

thừa từ một lớp nào nữa, điều này hạn chế việc tái sử dụng mã.

Phụ lục
- 194 -

Hình 8-1 Lớp triển khai interface của Grid service bằng kỹ thuật kế thừa.

GT3 đưa một hướng tiếp cận mới để giải quyết khuyết điểm của kỹ thuật sử
dụng tính kế thừa, đó là kỹ thuật uỷ quyền. Hướng tiếp cận này cho phép phân tán
các nhóm phương thức vào các lớp khác nhau, các lớp này được gọi là Operation
Provider. Như trên hình 0-2, có thể chia lớp MathImpl thành 3 lớp, ứng với từng
nhóm phương thức. Hình 8-2 Cài đặt intrface củaGrid service bằng kỹ thuật Operation Provider

Lưu ý là 3 lớp này không thừa kế từ lớp nào hết, chúng chỉ cài đặt một interface
tên là Operation Provider. Lúc này các chức năng của lớp GridServiceImpl không
được kế thừa từ đây mà được yêu cầu Grid service container cung cấp thông qua
bản đặc tả triển khai. Khi tiến hành cài đặt theo cách tiếp cận này, có một số thay
đổi nhỏ so với kỹ thuật sử dụng tính kế thừa, như trình bày dưới đây.


//Khai bao ten cac phuong thuc duoc cung cap, tuong ung voi file GWSDL
private static final QName[] operations =
new QName[]
{ new QName(namespace, "add"),
new QName(namespace, "subtract"),
new QName(namespace, "getValue") };

private GridServiceBase base;

// Cac phuong thuc cua Operation Provider
public void initialize(GridServiceBase base) throws GridServiceException {
this.base = base;
}
public QName[] getOperations() {
return operations;
}

//Cai dat
private int value = 0;
public void add(int a) throws RemoteException
{
value = value + a;
}
// tuong tu MathImpl
}

File đặc tả triển khai cũng có một số thay đổi, file :

$GRIDSER_DEMO/org/globus/progtutorial/services/core/providers/serv

Provider"/>

<!—Tuong tu tren >
</deployment>

Các thao tác khác để triển khai service hoàn toàn tương tự như đã giới thiệu ở
trên.C
C
.
.
2
2
.
.T
T
h
h
ê
ê
m
mt

i


u
u(
(
S
S
e
e
r
r
v
v
i
i
c
c
e
eD
D
a
a
t

)
)
)Như đã biết, mỗi Grid service đều có các SDE của riêng mình, phần này sẽ xem
xét kỹ thuật thêm SDE cho một service. Ở đây chúng ta thêm một SDE có tên là
MathData chứa các thông tin như giá trị hiện tại (value), phép toán thực hiện cuối
cùng (lastOp), số phép toán đã thực hiện (numOp), MathData chỉ có một và chỉ một
giá trị (cardinality = 1 1) được mô tả trên hình 0-3:

Hình 8-3 Ví dụ về SDE của MathService

+ Đặc tả SDE
Việc định nghĩa một SDE cho một service thông qua file đặc tả GWSDL, tuy
nhiên MathData là một kiểu phức tạp nên mặc dù có thể đặc tả kiểu này trong file
GWSDL, chúng ta có thể đặc tả trong một file khác. File :
$GRIDSER_DEMO/schema/progtutorial/MathService_sd/MathSDE.xsd

<complexType name="MathDataType">
<sequence>
<element name="value" type="int"/>
<element name="lastOp" type="string"/>
<element name="numOps" type="int"/>
</sequence>
</complexType>



+ Khai báo SDE trong đặc tả interface

<gwsdl:portType name="MathPortType" extends="ogsi:GridService">

<! <operation>s >

<sd:serviceData name="MathData"
type="data:MathDataType"
minOccurs="1"
maxOccurs="1"
mutability="mutable"
modifiable="false"
nillable="false">
</sd:serviceData>
</gwsdl:portType>

+ Cài đặt SDE
File :
$GRIDSER_DEMO/org/globus/progtutorial/services/core/servicedata/im
pl/MathImpl.java
Ở đây khai báo lớp không thay đổi:
public class MathImpl extends GridServiceImpl implements MathPortType

Lớp cài đặt này có thêm 2 thuộc tính private mới :
private ServiceData mathDataSDE; //La SDE
private MathDataType mathDataValue; //Chua gia tri cua SDE

}

Các hàm add(), substract() có thêm các lệnh mới để cập nhật lại SDE:

public void add(int a) throws RemoteException
{
//Cac ham setLastOp(),setValue(),setNumOps(), getNumOps() duoc tu
//dong phat sinh tu file dac ta MathSDE.xsd

mathDataValue.setLastOp("Addition");
incrementOps();
mathDataValue.setValue(mathDataValue.getValue() + a);
}

// Ham nay cap nhat MathData SDE tang so phep toan len 1
private void incrementOps()
{
int numOps = mathDataValue.getNumOps();
mathDataValue.setNumOps(numOps + 1);
}

+ Đặc tả cài đặt
Trong file đặc tả chỉ cần thay đổi lại các giá trị tương ứng tên các file mới
vừa tạo ra.
<parameter name="baseClassName"
value="org.globus.progtutorial.services.core.servicedata.impl.MathImpl"
/>
<parameter name="className"
value="org.globus.progtutorial.stubs.MathService_sd.MathPortType
"/>

MathPortType math = mathServiceLocator.getMathServicePort(GSH); // Lay SDE "MathData", su dung phuong thuc findServiceData cua
GridServiceImpl
ExtensibilityType extensibility =
math.findServiceData(QueryHelper.getNamesQuery("MathData"));

ServiceDataValuesType serviceData =
AnyHelper.getAsServiceDataValues(extensibility);

MathDataType mathData =
(MathDataType) AnyHelper.getAsSingleObject(serviceData,
MathDataType.class);

// Xuat cac gia tri cua SDE ra man hinh
System.out.println("Value: " + mathData.getValue());
System.out.println("Previous operation: " + mathData.getLastOp());
System.out.println("# of operations: " + mathData.getNumOps());

// Goi phuong thuc cua service.
math.add(a);
}catch(Exception e)
{
System.out.println("ERROR!");
e.printStackTrace();
}
}
}

c
c
h
h
ế
ếN
N
o
o
t
t
i
i
f
f
i
i
c
c
a
a
t
t
i
i

Có thể thấy đây là cơ chế “push” notification, GT3 chỉ hỗ trợ duy nhất dạng
này. Dưới đây, chúng ta sẽ xem xét chi tiết k
ỹ thuật cài đặt notification này trong
GT3 với MathService.

+ Khai báo sử dụng Notification trong portType
Thêm cơ chế Notification ảnh hưởng đến interface do chúng ta cần cung cấp
một số phương thức mới ra bên ngoài. Tất nhiên, chúng ta không cần cài đặt các
phương thức này mà chỉ cần khai báo sử dụng lại portType NotificationSource có
sẵn, portType này chứa đầy đủ các phương thức liên quan đến cơ chế Notification.
Do đó file GWSDL ở trên chỉ cần sửa lại như sau: File :
$GRIDSER_DEMO/schema/progtutorial/MathService_sd_notif/Math.gwsdl

<! Khai bao su dung lai portType NotificationSource >
gwsdl:portType name="MathPortType" extends="ogsi:GridService
ogsi:NotificationSource">

<! <cac operation> >

<! <serviceData> >

</gwsdl:portType>

+ Cài đặt
Chúng ta chỉ cần thêm một lệnh duy nhất trong các hàm cài đặt. File :
$GRIDSER_DEMO/org/globus/progtutorial/services/core/notifications/
impl/MathImpl.java

public void add(int a) throws RemoteException
{

+ Client
Client ở đây phức tạp hơn so với các ví dụ trước. Client trong Java (hay đúng
hơn là lớp nhận các thông báo) phải cài đặt phương thức deliverNotification,
phương thức này sẽ được Grid service gọi khi có sự thay đổi trong SDE của mình.
Mã nguồn client như sau, file :
$GRIDSER_DEMO/org/globus/progtutorial/clients/MathService_sd_notif
/ClientListener.java

//Cac khai bao import

public class ClientListener
extends ServicePropertiesImpl implements NotificationSinkCallback
{
public static void main(String[] args)
{
// Lay tham so dong lenh
HandleType GSH = new HandleType(args[0]);
ClientListener clientListener = new ClientListener(GSH);
}

public ClientListener(HandleType GSH) throws Exception
{
// Bat dau dang ky va lang nghe MathService
NotificationSinkManager notifManager =
NotificationSinkManager.getManager();

notifManager.startListening(NotificationSinkManager.MAIN_THREAD);

String sink = notifManager.addListener("MathData", null, GSH, this);
System.out.println("Listening ");

MathDataType mathData = (MathDataType)
AnyHelper.getAsSingleObject(serviceData, MathDataType.class);

// Xuat ra man hinh
System.out.println("Current value: " + mathData.getValue());
System.out.println("Previous operation: " + mathData.getLastOp());
System.out.println("# of operations: " + mathData.getNumOps());
}catch(Exception exc)
{
System.out.println("ERROR!");
exc.printStackTrace();
}
}
}

C
C
.
.
7
7
.
.C
C
à
à
i

t


o
os
s
e
e
r
r
v
v
i
i
c
c
e

đ


n
n
g

r
v
v
i
i
c
c
e
e
)
)Làm cho một service có khả năng được tạo lập một cách động (chuyển service
thành transient service) là một trong những việc dễ dàng nhất trong GT3, chúng ta
không cần thay đổi portType cũng như cài đặt của nó. Mọi thứ cần làm là sửa lại
file đặc tả cài đặt.
+ Đặc tả cài đặt
Để có thể thấy rõ hơn về sự thay đổi, chúng ta xem lại file WSDD cũ:
<?xml version="1.0"?>
<deployment name="defaultServerConfig"
xmlns="
xmlns:java="

<service
name="progtutorial/core/first/MathService" provider="Handler"
style="wrapped">

<parameter name="name" value="MathService"/>


$GRIDSER_DEMO/org/globus/progtutorial/services/core/first/server-
deploy.wsdd

<?xml version="1.0"?>
<deployment name="defaultServerConfig"
xmlns="
xmlns:java="

<service name="progtutorial/core/first/MathFactoryService"
provider="Handler"
style="wrapped">

<parameter name="name" value="MathService Factory"/>
<parameter name="instance-name" value="MathService Instance"/>
<parameter name="instance-schemaPath"
value="schema/progtutorial/MathService/Math_service.wsdl"/>
<parameter name="instance-baseClassName"
value="org.globus.progtutorial.services.core.first.impl.MathImpl"/>
<parameter name="instance-className"
value="org.globus.progtutorial.stubs.MathService.MathPortType"/>

<!—Cac tham so chung >
<parameter name="allowedMethods" value="*"/>
<parameter name="persistent" value="true"/>
<parameter name="handlerClass"
value="org.globus.ogsa.handlers.RPCURIProvider"/>

<parameter name="className"
value="org.gridforum.ogsi.Factory"/>
<parameter name="baseClassName"

+ Có thể thấy, việc thêm khả năng tạo lập động cho bất kỳ service nào,
đơn giản chỉ gồm 2 bước, thêm các tiền tố “instance-” và sửa lại “khối tham số
chung”

+ Đối với client
Có thể sử dụng lại các client cũ. Ở đây, chúng ta viết một client để demo khả
năng tạo lập, sử dụng và huỷ một service instance thông qua Factory.
File :
$GRIDSER_DEMO/org/globus/progtutorial/clients/MathService/FactoryC
lient.java

package org.globus.progtutorial.clients.MathService;

import org.gridforum.ogsi.OGSIServiceGridLocator;
import org.gridforum.ogsi.Factory;
import org.gridforum.ogsi.LocatorType;
import org.globus.ogsa.utils.GridServiceFactory;

import
org.globus.progtutorial.stubs.MathService.service.MathServiceGridLocator;
import org.globus.progtutorial.stubs.MathService.MathPortType;

import java.net.URL;

public class FactoryClient
{
public static void main(String[] args)
{
try
{ Phụ lục
- 205 -
}
}
}
C
C
.
.
5
5
.
.K
K

ỹt
t
h
h
u

iv
v
ế
ế
t
t
)
)Logging là một kỹ thuật quan trọng trong phát triển và bảo trì phần mềm, cho
phép theo dõi các sự kiện đặc biệt của hệ thống, các sự kiện ghi nhận có thể được
kết xuất ra màn hình. GT3 cung cấp khả năng logging theo mô hình Apache Jakarta
Commons Logging ( />). Mô hình này đưa
ra 6 cấp độ thông tin logging, gồm Debug, Trace, Info, Warn, Error, Fatal. Việc
quyết định thông tin nào ở mức độ nào là tuỳ thuộc vào người lập trình ứng dụng.
Ở đây chúng ta sẽ thêm tính năng logging vào MathService, sử dụng lại ví dụ
đầu tiên. Khi thêm tính năng logging, chúng ta không cần sửa lại portType, chỉ cần
thêm các lệnh cần thiết vào mã cài đặt portType.

+ Cài đặt
File:
$GRIDSER_DEMO/org/globus/progtutorial/services/core/logging/impl/M
athImpl.java

//


$GLOBUS_LOCATION/ogsilogging.properties(Đây là file cấu hình Log
của GT3) Phụ lục
- 206 -
#Cho biet can xuat cac log o cap do Info ra man hinh console, co the
sua #lai cac cap do khac, va ghi ra file
org.globus.progtutorial.services.core.logging.impl.MathImpl=console,in
fo
C
C
.
.
6
6
.
.K
K



c
c
h
h
u
ut
t
r
r
ì
ì
n
n
h
hs
s


n
n
g
g
f
f
e
e
c
c
y
y
c
c
l
l
e
eM
M
a
a
n
n
a
a
g
g
e
e
m
m

File :
$GRIDSER_DEMO/org/globus/progtutorial/services/core/lifecycle/impl
/MathImpl.java

//
import org.globus.ogsa.GridServiceCallback;
//
public class MathImpl extends GridServiceImpl
implements MathPortType, GridServiceCallback
{
//
// Cai dat cac phuong thuc Callback, chi can su dung lai cac ham cai san cua
lop cha GridServiceImpl

public void preCreate(GridServiceBase base) throws GridServiceException
{
super.preCreate(base);
logger.info("Instance is going to be created (preCreate)");
}
public void postCreate(GridContext context) throws GridServiceException
{ Phụ lục

callback được gọi tại các thời điểm quan trọng trong thời gian sống của Grid
service. Chúng ta không cần kế thừa hay tham thảo interface này trực tiếp từ mã
nguồn. Chúng ta chỉ cần thêm một dòng vào bản đặc tả triển khai yêu cầu lớp
lifecycle monitor phải được gọi khi có sự kiện đặc biệt xảy ra. Do đó, chúng ta có
thể dùng cùng một lifecycle monitor cho nhiều Grid service khác nhau.
Dưới đây là một lớp lifecycle monitor đơn giản, file :
$GRIDSER_DEMO/org/globus/progtutorial/services/core/lifecycle/impl
/MathLifecycleMonitor.java
package org.globus.progtutorial.services.core.lifecycle.impl;

import org.globus.ogsa.GridServiceException;
import org.globus.ogsa.ServiceLifecycleMonitor;
import org.globus.ogsa.GridContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class MathLifecycleMonitor implements ServiceLifecycleMonitor
{
// Tao logger cho lop
static Log logger = LogFactory.getLog(MathLifecycleMonitor.class.getName());

//Cac phuong thuc can callback
public void create(GridContext context) throws GridServiceException
{
logger.info("Instance is going to be created (create)");
}


Và thêm dòng sau vào file đặc tả triển khai (.WSDD)

<parameter name="lifecycleMonitorClass"
value="org.globus.progtutorial.services.core.lifecycle.impl.MathLifecycleMonitor"/>

D
D
.
.C
C
á
á
c
ci
i
n
n
t
t
e
e
r
r

S
S
I
IS
S
e
e
r
r
v
v
i
i
c
c
e
e
Bảng 0-3 tóm tắt các interface của một Grid Service được định nghĩa trong
OGSI 1.0:

Interface Loại Tên chi tiết Diễn giải
Định nghĩa các ứng xử cơ bản của một service.
interface Danh sách tên (QName) các
interface của service.

rộng của phương thức
findServiceData
setServiceDataExtensibility
Tập các phương thức mở
rộng của phương thức
setServiceData
terminationTime
Thời gian dự kiến kết thúc
của service instance. findServiceData
Truy vấn thông tin của
service.
setServiceData
Cho phép thay đổi giá trị các
SDE được phép thay đổi giá
trị. (modifiable= “true”)
requestTerminationAfter
Yêu cầu thay đổi
terminationTime của service
instance. Phương thức này
xác định thời gian kết thúc
sớm nhất có thể được.
requestTerminationBefore
Yêu cầu thay đổi
terminationTime của service
instance. Phương thức này
xác định thời gian kết thúc trễ
nhất có thể được.

rộng của phương thức
subscribe
SDE

Notification
Source

Phương
thức
subscribe
Yêu cầu phải được thông báo
mỗi khi có sự thay đổi của
các SDE xác định trong
notifiableServiceDataName.
Định nghĩa phương thức phân phối các thông điệp Phụ lục
- 210 -
Định nghĩa phương thức phân phối các thông điệp
SDE Không có
Notification
Sink


Tạo service instance mới.
Cho phép client quản lý một nhóm các service.
membershipContentRule
Là một cấu trúc liên kết một
portType với một tập các
QName. Mỗi service instance
nếu muốn là thành viên của
nhóm phải có một hoặc nhiều
interface xác định trong SDE
này.
SDE
entry
Biểu diễn thông tin về một
thành viên của ServiceGroup.
Service
Group

Phương
thức
Không có
Cho phép thêm và loại bỏ các Grid service instance trong các
ServiceGroup,
addExtensibility
Tập các phương thức mở
rộng của phương thức add
removeExtensibility
Tập các phương thức mở
rộng của phương thức
remove
SDE
Phụ lục
- 211 -
content
Cung cấp một số thông tin về
service instance đang chứa.
Phương
thức
Không có
Bảng 8-3 Các interface của một OGSI Service
E
E
.
.C
C


u
ut
t

h
h

ỉđ
đ
i
i


n
nt
t

ửMột chứng chỉ điện tử bao gồm các phần chính : một subject (distinguished
name (DN)) duy nhất trong không gian tên của hệ thống Grid xác định người hoặc
đối tượng mà chứng chỉ đại diện, một khóa công khai đi kèm với subject, phần nhận
dạng CA thực hiện ký chứng nhận chứng chỉ, chữ ký của CA và phần mở rộng chứa
thông tin về cá nhân hay host được chứng nhận. Một số thông tin có thể là địa chỉ

email, tên tổ chức, …
Hình vẽ sau mô tả chi tiết cấu trúc một chứng chỉ điện tử:

Việc yêu cầu chứng thực trên trên đây chỉ cần thực hiện một lần duy nhất,
từ khi nhận được chứng chỉ, người dùng có thể dùng nó đế đại diện cho mình
khi giao tiếp với bất kỳ hệ thống nào có yêu cầ
u chứng thực.

Phụ lục
- 213 -
T
T
à
à
i
il
l
i
i



[3] Ian Foster, What is the Grid? A Three Point Checklist, Argonne National
Laboratory & University of Chicago, 20/06/2002.

[4] Ian Foster,Carl Kesselman, Jeffrey M. Nick, Steven Tuecke, The Physiology of
the Grid - An Open Grid Services Architecture for Distributed Systems
Integration, Version: 6/22/2002.

[5] I. Foster, D. Gannon, H. Kishimoto, The Open Grid Services Architecture,
GLOBAL GRID FORUM, 10/03/2004, />wg

[6] S. Tuecke, K. Czajkowski, I. Foster, J. Frey, S. Graham, C. Kesselman, T.
Maquire, T. Sandholm, D. Snelling, P. Vanderbilt, Open Grid Services
Infrastructure (OGSI) Version 1.0, GLOBAL GRID FORUM, 27/06/2003,
/>

[7] Mark Baker, Rajkumar Buyya, Domenico Laforenza, Grids and Grid
technologies for wide-area distributed computing, John Wiley & Sons Ltd, 2002

[8] Steven Fitzgerald, Ian Foster, Carl Kesselman, Gregor von Laszewski,
Warren Smith, Steven Tuecke, A Directory Service for Configuring
High-Performance Distributed Computations, 1997,

[9] Ian Foster, Carl Kesselman, Globus: A Metacomputing Infrastructure Toolkit,
[10] Karl Czajkowski, Steven Fitzgerald, Ian Foster, Carl Kesselman, Grid
Information Services for Distributed Resource Sharing, Proc. 10th IEEE
International Symposium on High-Performance Distributed Computing (HPDC-
10), IEEE Press, 2001.


[16] Bart Jacob, How Grid infrastructure affects application design, RedBooks,
IBM, 06/2003.

[17] Bart Jacob, Taking advantage of Grid computing for application enablement,
RedBooks, IBM, 06/2003.

[18] Martin C. Brown, Grid computing moving to a standardized platform,
RedBooks, IBM, 08/2003.

[19] IBM Corp. , The Era of Grid Computing: A new standard for successful IT
strategies, 01/2004, www.ibm.com[20] Viktors Berstis, Fundamentals of Grid Computing, Redbooks, IBM Corp, 2002,
www.ibm.com/redbooks[21] Luis Ferreira,Viktors Berstis, Jonathan Armstrong, Mike Kendzierski, Andreas
Neukoetter, Introduction to Grid Computing with Globus, Redbooks,IBM Corp,
09/2003, www.ibm.com/redbooks[22] Bart Jacob, Luis Ferreira, Norbert Bieberstein, Candice Gilzean, Jean-Yves
Girard, Roman Strachowski, Seong (Steve) Yu, Enabling Applications for Grid
Computing with Globus, Redbooks, IBM Corp, 06/2003,
www.ibm.com/redbooks[23] Luis Ferreira, Bart Jacob, Sean Slevin, Michael Brown, Srikrishnan Sundararajan,

Middleware Technologies, Grid Computing and Distributed Systems (GRIDS)
Laboratory, The University of Melbourne, Australia

[28] Matthew Strebe, Network Security JumpStart, SYBEX Inc., 2002

[29] James Stanger, Patrick Lane, Tim Crothers, CIW:Security Professional
Study Guide, SYBEX Inc., 2002, www.sybex.com[30] Wenke Lee, Salvatore J. Stolfo, Kui W. Mok, Adaptive Intrusion Detection: a
Data Mining Approach, Kluwer Academic Publishers, 2000.

[31] John McHugh, Alan Christie, Julia Allen, Defending Yourself: The Role of
Intrusion Detection Systems, IEEE SOFTWARE, 10/2000.

[32] Thomas H. Ptacek, Timothy N. Newsham, Insertion, Evasion, and Denial of
Service:Eluding Network Intrusion Detection, Secure Networks Inc.,01/1998

[33] Detmar Liesen, Requirements for Enterprise-Wide Scaling Intrusion Detection
Products, 2002

[34] William Allcock, Programming with GridFTP Client Library,
CLUSTERWORLD volume 2 no 9 , pp. 1-6, 10/2004

[35] Globus Alliance, MDS ver 2.2 User’s Guide, Globus Aliance, www.globus.org
,
3/10/2003.

[36] William Allcock, GridFTP: Protocol Extensions to FTP for the Grid, Argonne
National Laboratory, 03/2003


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status