33
The Jini Technology Lookup Service

The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Embed Size (px)

Citation preview

Page 1: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

The Jini Technology Lookup Service

Page 2: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

How Does It Work

Services and clients find a lookup service using the discovery protocol

Services advertise themselves by registering with the lookup service

Clients query the lookup service to find the services they need

Peer-to peer communication between client and service after that

Page 3: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Discovery/Join and Lookup Protocols

Figure 1 Discovery

Page 4: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Discovery/Join and Lookup Protocols

Figure 2 Join

Page 5: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Discovery/Join and Lookup Protocols

Figure 3 Lookup

Page 6: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Discovery/Join and Lookup Protocols

Figure 4 Service Invocation

Page 7: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Discovery and Join

How does a client or service find lookup services

How does a service join a lookup serviceHow does a client know which ones to do

lookups in

Page 8: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Initial Discovery

Performed by both clients and servicesSend multicast request packet

Groups you are looking for Host and TCP port to use contact you

Waiting for lookup services to connect back

Download lookup service’s proxy object Register with or do lookup in

Page 9: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Lookup Service

Network service For finding other network services “Workgroup”-scale, not the entire Internet

Not a naming or directory serviceFocus is on types, not names

Yellow pages, not white pages

Both programmatic and end-user access

Page 10: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Lookup Service 101

Each service registers its proxy objectClient does lookup by interface type

Instance of semantics API uses java.lang.Class instances, not strings

Client gets proxy object back Needed classes are automatically downloaded

Proxy communicates with remote service

Page 11: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Service Type Matching

Can match on any type Interface or concrete class Including super interface or superclass Can get subinterface or subclass back

Java.lang.Object match everythingCan match using multiple types

Page 12: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Service Type Matching

“I want a combination TV/VCR” org.Ce.TV AND org.Ce.VCR

Yellow pages Automatic placement in all categories

Base class and all interfaces All superclasses and superinterfaces

Page 13: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Attributes

Service can also register with attributesAttributes allow further discrimination

between services of the same typeLookup support matching on

Just service types Just attributes Combinations

Page 14: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Example Generic Attributes

NameLocationManufacturerModel

Page 15: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Example Printer Attributes (1)

Monochrome or colorResolutionSpeedPaper size

Page 16: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Attribute Characteristics

Some are defined by service itself e.g., manufacturer, model, resolution

Some are defined by administrator e.g., Name, location

Attributes can have multiple values

Page 17: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Example Printer Attributes (2)

Printer supports these combinations Monochrome, 600 dpi, 10 ppm Monochrome, 300 dpi, 15 ppm Color, 300 dpi, 5 ppm

For each combination, printer supports Letter Legal Envelope

Page 18: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Attribute Representation

Each attribute is a public field of a class Attribute name = field name Attribute type = field type

Each class defines an attribute set Co-dependent attributes in the same class Orthogonal attributes in different classes

Each service has set of attribute sets Instances of multiple classes Multiple instances of the same class

Page 19: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Example Printer Attribute (3)

PrintEngine{color: false, dpi: 600, ppm: 10}

PrintEngine{color: false, dpi: 300, ppm: 15}

PrintEngine{color: false, dpi: 300, ppm: 5}

PaperSize{size: PaperType.Letter}

PaperSize{size: PaperType.Legal}

PaperSize{size: PaperType.Envelope}

Location{floor: “3”, room: “1234”, building: “A1”}

Name{name: “rainbow”}

Page 20: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Attribute Set Matching

Match on attribute set class Including superclasses

Match on attribute values (fields) Exact value match only

java.rmi.MarshalledObject.equals

Template is just an attribute set instance Null field = match any value (wildcard)

Page 21: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Matching Examples

template PrintEngine{color: false, dpi: null,

ppm: null}

matches PrintEngine{color: false, dpi: 600, ppm: 10}

and PrintEngine{color: false, dpi: 300, ppm: 15}

Page 22: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Matching Examples

template PrintAttrs{}

matches PrintEngine{color: true, dpi: 300,

ppm: 5}

and PageSize{size: Legal}

Page 23: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Service Registration

Service registers by providing: Service id

Every service has a universally unique id Lookup service will assign one if requested

Proxy object Zero or more attribute sets

Page 24: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Service Registration

public class ServiceItem implements

java.io.Serializable {

public ServiceID serviceID;

public Object service;

public Entry [ ] attributeSets;

}

Page 25: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Service Template

Service template contains: Optional service id

Null is wildcard = match any

Zero or more service types Zero or more attribute set templates

Null fields are wildcards = match any

Page 26: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Service Template

public class ServiceTemplate implements

java.io.Serializable {

public ServiceID serviceID;

public Class [ ] serviceTypes;

public Entry [ ] attributeSetTemplates;

}

Page 27: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Template Matching

Service registration matches template if: Service id matches, and Proxy is instance of each service type, and For each attribute set template:

Service has a matching attribute set

Page 28: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Example Queries

Any service named “rainbow”Any Printer named “rainbow” in A1Any color envelope PrinterAll services on floor 3

Page 29: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Complex Queries

“Between 300 and 600 dpi”“On floor 1, 3, or 7”“Letter or Legal”“Printer or Copier”

Page 30: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Complex Queries

Technique 1 Change ranges and ors to wildcards Do single template-based lookup Then do finer-grained match locally

Technique 2 Query for actual values in ranges and ors Do multiple lookups

Page 31: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Attribute Modification

Can only be done by service itself Allows service to control policy

Internal state changes

Administrative interfaces

Service is responsible for persistent storage

Add, modify, delete, replace allAttributes should change infrequently

Primary search keys Query service directly for very dynamic state

Page 32: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Lookup Groups

Each lookup service is configured with s set of group names Is in (is a member of) each group

Each service is configured with a set of group names Registers with all lookup services in any of those

groupsEach client is configured with a set of group

names Uses lookup service in any of those groups

Page 33: The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves

Summary

Service perspective Register with desired attributes Keep renewing registration lease Add, modify, delete attributes as desired

Client perspective Lookup any 1 of

Get just proxy object

Lookup to N of Get proxies attributes, and service IDS