The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service...

Preview:

Citation preview

The Jini Technology Lookup Service

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

Discovery/Join and Lookup Protocols

Figure 1 Discovery

Discovery/Join and Lookup Protocols

Figure 2 Join

Discovery/Join and Lookup Protocols

Figure 3 Lookup

Discovery/Join and Lookup Protocols

Figure 4 Service Invocation

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

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

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

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

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

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

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

Example Generic Attributes

NameLocationManufacturerModel

Example Printer Attributes (1)

Monochrome or colorResolutionSpeedPaper size

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

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

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

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”}

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)

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}

Matching Examples

template PrintAttrs{}

matches PrintEngine{color: true, dpi: 300,

ppm: 5}

and PageSize{size: Legal}

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

Service Registration

public class ServiceItem implements

java.io.Serializable {

public ServiceID serviceID;

public Object service;

public Entry [ ] attributeSets;

}

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

Service Template

public class ServiceTemplate implements

java.io.Serializable {

public ServiceID serviceID;

public Class [ ] serviceTypes;

public Entry [ ] attributeSetTemplates;

}

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

Example Queries

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

Complex Queries

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

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

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

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

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

Recommended