26
Jini Technology 제 1 제 제제 제제 제제제 제제제제 발발발 : 제제제 Email : [email protected] 발발발 @idosi.com Mobile : 016-201-5053 발발 : 제 idosi.com 발발발발 발발 : JavaCommunity.Org 발발발발 : 2000 발 4 발 9 발

Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Embed Size (px)

DESCRIPTION

Jini Home Network

Citation preview

Page 1: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Jini Technology

제 1 회 한국 자바 개발자 컨퍼런스

발표자 : 강신동Email : [email protected] 강신동 @idosi.comMobile : 016-201-5053소속 : ㈜ idosi.com 대표이사주최 : JavaCommunity.Org발표일자 : 2000 년 4 월 9 일

Page 2: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

목 차1. Jini 개요2. Jini site 와 개발도구3. bytecode 이동과 instance 이동4. Discovery5. Join6. Lookup7. Lookup reservation8. Lease9. Using back-end process10. RMI diagram11. Jini diagram

강신동 ([email protected],t , 강신동 @idosi.com)

Page 3: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Jini Home Network

Page 4: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Jini Client - Server

Web server chip

Jini 의 실예

강신동 ([email protected],t , 강신동 @idosi.com)

Page 5: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Jini site 와 개발도구

JDK 1.2 (Java 2) 이상rmid : lookup daemon

Jini Technology Starter Kit (jini1.1 alpha) reggie : sun’s lookup servicehttpd

web server for downloading rmi’s stub class

Lookup service 이용을 위한 기본도구

Jini web sitehttp://java.sun.com/jinihttp://www.jini.orghttp://artima.com/jinihttp://jiniworld.chonnam.ac.kr

강신동 ([email protected],t , 강신동 @idosi.com)

Page 6: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

bytecode 이동과 instance 이동

bytecode 의 network 이동

instance 의 network 이동

Ex) appletclient 중심개념실행코드가 run-time 상태의 client JVM 으로 이동모든 instance 는 client 의 JVM 에서 생성된다

Ex) Jiniservice 중심개념interface 이용실행코드와 data 의 run-time 시 이동service 에서 만들어진 instance 가 동적으로 client 의

JVM 에서 즉시 이용될 수 있는 특징network 에서 이동된 instance 는 client 에서 만들어진 instance 처럼 이용

강신동 ([email protected],t , 강신동 @idosi.com)

Page 7: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Discovery

Lookup-service

ServiceClient

Service 는 자신을 등록하기 위해 network 상에서 Lookup service 를 찾는다 .

Client 는 등록된 Service 를 찾기 위해 network 상에서 Lookup service 를 찾는다 .

강신동 ([email protected],t , 강신동 @idosi.com)

Page 8: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Discovery protocolLookup ServiceDiscoverer

Request messageUDP multicast

Response messageTCP unicast

Multicast request protocol

Lookup ServiceDiscoverer

Request messageTCP unicast

Response messageTCP unicast

Multicast announcement protocol

Announcement messageUDP multicast

Request messageTCP unicast

Response messageTCP unicast

Unicast discovery protocol강신동 ([email protected],t , 강신동 @idosi.com)

Page 9: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Discovery (receive ServiceRegistrar)

Lookup-service

Service

Client

ServiceRegistrar

ServiceRegistrar

Service JVM

Client JVM

Lookup JVM

강신동 ([email protected],t , 강신동 @idosi.com)

Page 10: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Discovery (code)UnicastDiscovery

MulticastDiscovery

Lookup-service 의 위치를 알고있는 경우TCP/IP Socket 이용 직접 접속 (port 4160)synchronous processingLookupLocator lookup = new LookupLocator(“jini://jini.idosi.com”); ServiceRegistrar registrar = lookup.getRegistrar();

Lookup-service 의 위치를 모르는 경우Multicast 이용 lookup-service 응답기다림service 에서 cient 로 TCP/IP Socket 이용연결asynchronous processingLookupDiscovery discover = new LookupDiscovery(LookupDiscovery.ALL_GROUPS);discovery.addDiscoveryListener(listener);public void discovered(DiscoveryEvent evt){ ServiceRegistrar[] registrars = evt.getRegistrars();}

강신동 ([email protected],t , 강신동 @idosi.com)

Page 11: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Join (service copy)

Service

Service Copy

Service Proxy

ServiceRegistrar

ServiceItem

ServiceItem

Service JVM

강신동 ([email protected],t , 강신동 @idosi.com)

Page 12: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Join (regist service proxy)

Lookup-service

Service

Service Copy

Service Proxy registerServiceRegistrar

Service JVM

Lookup JVM

강신동 ([email protected],t , 강신동 @idosi.com)

Page 13: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Join (code)

ServiceRegistrar registrar = …;ServiceID id = null; // 전세계에서 유일한 id 부여 Entry entry = null; // service 의 부가정보제공MyServiceInterface proxy = createServiceInterfaceInstance();ServiceItem item = new ServiceItem(id, proxy, entry);long leaseTime = 1 * 60 * 1000; // msecServiceRegistration registration = registrar.register(item, leaseTime);

강신동 ([email protected],t , 강신동 @idosi.com)

Page 14: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lookup (receive service copy)

Lookup-service

Lookup JVMClient

ServiceTemplate

Service copy

Client JVM

강신동 ([email protected],t , 강신동 @idosi.com)

Page 15: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lookup (code)

ServiceRegistrar registrar = …;ServiceID id = null; // 전세계에서 유일한 id 부여 Entry entry = null; // service 의 부가정보제공Class[] types = { MyServiceInterface.class };ServiceTemplate template = new ServiceTemplate(id, types, entry);Object o = registrar.lookup(template);if (o instanceof MyServiceInterface){ MyServiceInterface service = (MyServiceInterface) o; Object result = service.callMyMethod();}

강신동 ([email protected],t , 강신동 @idosi.com)

Page 16: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lookup Reservation

Client

ServiceTemplate

Client JVM

RemoteEventListener

Lookup-service

Lookup JVM

notify

notifyServiceEvent

ServiceItem Service Copy

강신동 ([email protected],t , 강신동 @idosi.com)

Page 17: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lookup Reservation (code)

ServiceRegistrar registrar = …..;Entry entry = null;long leaseTime = 1 * 60 * 1000;EventRegistration evtreg = registrar.notify(template, ServiceRegistrar.TRANSITION_NOMATCH_MATCH, myRemoteEventListener, entry, leaseTime);MyRemoteEventListener extends UnicastRemoteObject implements RemoteEventListenerpublic void notify(RemoteEvent evt) throws RemoteException, UnknownEventException{ if (evt instanceof ServiceEvent) { ServiceEvent sevt = (ServiceEvent) evt; ServiceItem item = sevt.getServiceItem(); MyServiceInterface service = (MyServiceInterface) item.service; Object result = service.callMyMethod(); }}

강신동 ([email protected],t , 강신동 @idosi.com)

Page 18: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lookup federation topologyCommunity of communities

Hierarchies Stars Island

강신동 ([email protected],t , 강신동 @idosi.com)

Page 19: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lease (service side)

Lookup-service

Serviceregister

ServiceRegistrar

Service JVM Lookup JVM

ServiceRegistration

Leaserenew()

강신동 ([email protected],t , 강신동 @idosi.com)

Page 20: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lease (service code)

ServiceRegistration registration = registrar.register(…….);public void run() { while (true) { try { Lease lease = registration.getLease(); long expiration = lease.getExpiration(); long sleepTime = computeSleepTime(); Thread.sleep(sleeptime); lease.renew( 1 * 60 * 1000); } } }

Lease expiration

time linenownow

renew zone

강신동 ([email protected],t , 강신동 @idosi.com)

Page 21: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lease (client side)

Lookup-service

notifyServiceRegistrar

Client JVM Lookup JVM

EventRegistration

Leaserenew()

Client

강신동 ([email protected],t , 강신동 @idosi.com)

Page 22: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Lease (client code)

ServiceRegistration servreg = registrar.register(……);Lease lease = servreg.getLease();long expiration = lease.getExpiration();if ( RENEW_ZONE){ lease.renew(LEASE_TIME);}

EventRegistration evtreg = registrar.notify(……);Lease lease = evtreg.getLease();long expiration = lease.getExpiration();if ( RENEW_ZONE){ lease.renew(LEASE_TIME);}

service renew lease

client renew lease

강신동 ([email protected],t , 강신동 @idosi.com)

Page 23: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Using Back-end Process

Lookup-service

Lookup JVM

Service

Service ProxyRemote Server

Client

RMI, Socket ...

Service JVM Client JVM

choke point

강신동 ([email protected],t , 강신동 @idosi.com)

Page 24: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

RMI diagram

RemoteInterface

RemoteImpl

UnicastRemoteObject

Skeleton Stub RemoteInterface

rmiregistry

webserver

client

Server JVMClient JVM

bind

lookup

rmi

stubcode

강신동 ([email protected],t , 강신동 @idosi.com)

Page 25: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Jini diagram (service copy)

MyInterface

Serializable

MyService

rmid (reggie)

register

MyInterface

client

lookup

MyService

Web server

MyInterface

Service JVM

Client JVM강신동 ([email protected],t , 강신동 @idosi.com)

Page 26: Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 016-201-5053…

Jini diagram (service proxy)

MyInterface Serializablermid (reggie)

register

MyInterface

client

lookup

MyInterface

Service JVMClient JVM

RemoteProtocol

proxy

proxy

RemoteInterrface

BackendSkeleton Stub

rmi

Web server