Distributed Programming in Java - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Distributed Programming in Java

Description:

{ try { PrintJob job = (PrintJob) jobs.take(); print(job) ... { try { System.setSecurityManager(new RMISecurityManager()); TupleSpace space = (TupleSpace) ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 28
Provided by: protonScs
Category:

less

Transcript and Presenter's Notes

Title: Distributed Programming in Java


1
Distributed Programming in Java
  • Review (2)

2
Topics
  • Concurrency
  • Networking and event handling
  • Baseline architecture
  • Remote objects
  • Web services
  • Space-based computing

3
Remote Objects
  • What problems?
  • location transparency
  • What mechanisms and Java constructs?
  • RMI
  • What patterns?
  • broker, client-server-dispatcher, proxy, and
    active object

4
Broker
  • Separate communication infrastructure from
    application functionality via a federation of
    brokers that mediates all the communication
    between the components of the system

5
Broker
  • Structure of the Broker pattern

6
Separation of Behavior and Implementation
  • Remote object behavior defined in an interface
    (Service)
  • Remote object behavior implemented in a server
    class (ServiceImpl)
  • Proxy sends request to remote object

Also see Broker pattern
7
Print Server
  • Remote server with callbacks to clients

8
Active Object
  • Objectify service invocations and let server
    (active object) schedule the execution

9
Applying the Pattern
1
3
2
10
PrinterImpl
public void submit(PrinterListener listener,
PrintJob job) throws RemoteException try
job.submittedBy listener jobs.put(job)
catch (InterruptedException e) public
void run() while (true) try PrintJob
job (PrintJob) jobs.take() print(job)
// process next job job.submittedBy. //
get callback client completed(job) //
notify the client catch (Exception e)
11
Web Services
  • What problems?
  • interoperability, deployment
  • What mechanisms and Java constructs?
  • SOAP, WSDL, Axis
  • What patterns?
  • service-oriented architecture, architecture
    adapter, and business objects
  • business process, and publish-subscribe
  • physical tiers, faux implementation

12
Web Services
  • What are web services? In essence, a technology
    for application integration based on open
    standards (HTTP, XML)
  • In what sense are they related to the Web
    (capital W to refer to the WWW)?
  • In fact, deploying web services over the web is
    more of an artefact than a necessity ...
  • What we care about is the web of services

13
Web of Services
  • Typical (recursive) composition of web services
    as a web of services

14
Service-Oriented Architecture
  • Servers describe their services in a WSDL
    document, and publish them (eg UDDI)
  • Clients bind to services (create proxies from
    WSDL), and invoke using SOAP

15
Architecture Adapter
  • WS frameworks such as Axis allow you to be fully
    WS-agnostic to access WS from Java use method
    calls via architecture adapters

16
Business Objects
  • Objects are marginalized in the SOA
  • Web services require a flat object model
  • If objects are passed as parameters, they need to
    be implemented as beans
  • In Axis, beans can be defined through
    ltbeanmappinggt tags in WSDD
  • Also applied to flow logic by moving it out from
    the programming language (BPEL !)

17
Using Axis Step by Step
  • Provide a Java interface or class that describes
    the service interface
  • Create WSDL using Java2WSDL tool
  • Create bindings through WSDL2Java tool
  • Implement the service interface
  • Deploy the service
  • Implement clients using generated stubs

18
Retailer
public void submitOrder(OrderHolder orderHolder)
throws NoSuchProductException,
NoItemCanBeShipped ... SupplierService
service new SupplierServiceLocator() //
contact the first supplier Supplier port1
service.getSupplier( new URL("http//localhost9
091/axis/services/Supplier")) port1.placeOrder(o
rderHolder) // check if order has been
satisfied if (!orderSatisfied(orderHolder.valu
e)) Supplier port2 service.getSupplier( n
ew URL("http//localhost9092/axis/services/Suppli
er")) port2.placeOrder(orderHolder) ...
19
Deployment
ltdeployment xmlns"http//xml.apache.org/axis/wsdd
/" xmlnsjava"http//xml.apache.org/axis/wsdd/p
roviders/java"gt ltservice name"Retailer"
provider"javaRPC"gt ltparameter
name"className" value"a3.retailer.RetailerImpl"/
gt ltparameter name"scope" value"Application"/gt
ltparameter name"allowedMethods"
value"submitOrder"/gt ltbeanMapping
qname"nsOrder" xmlnsns"urnRetailer"
languageSpecificType"javaa3.util.Order"/gt
ltoperation name"submitOrder"gt ltparameter
name"order" mode"INOUT"/gt lt/operationgt
ltbeanMapping qname"nsNoSuchProductException"
xmlnsns"urnRetailer" languageSpecificType"jav
aa3.retailer.NoSuchProductException"/gt
ltbeanMapping qname"nsNoItemCanBeShipped"
xmlnsns"urnRetailer" languageSpecificType"jav
aa3.retailer.NoItemCanBeShipped"/gt lt/servicegt
lt/deploymentgt
20
Business Process
21
Participants
  • BusinessProcess
  • Interface to the business process
  • BusinessProcessImpl
  • Logic of the business process, which can be a
    simple ActivitySequence
  • BusinessActivity
  • Unit of work in the business process
  • Data
  • Captures side effects of business activities (in
    this pattern a common pool)

22
Publish-Subscribe
23
Participants
  • Subscriber
  • Interface that event service calls to notify a
    client about an event it subscribed for
  • SubscriberImpl register with distinct URLs for
    receiving update messages
  • EventService
  • Subscribers can subscribe to events
  • Publishers can publish events, and events and
    data will be forwarded to subs

24
Space-Based Computing
  • What problems?
  • coordination
  • What mechanisms and Java constructs?
  • tuple spaces
  • What patterns?
  • supervisor-worker

25
Space-Based Computing
  • A space is a high-level coordination tool for
    glueing agents into an application
  • Different programming paradigm
  • Instead of relying on message-passing,
  • applications cooperate through the flow of
    objects in and out of spaces
  • Space-based models (JavaSpaces, TSpaces) based on
    tuple space concepts

26
CameraBuyer
public class CameraBuyer public static void
main(String args) try System.setSecurit
yManager(new RMISecurityManager()) TupleSpace
space (TupleSpace) Naming.lookup("rmi//"
args0 "/" args1) String make
args2 Tuple cameraTemplate new
Tuple("camera", new Field("make",
make), new Field("price", Integer.class))
System.out.println("Buyer.in "
cameraTemplate) Tuple camera
space.in(cameraTemplate) System.out.println("M
atch " camera) System.out.println("Camera.p
rice " camera.getField("price"))
catch (Exception e) System.err.println(e)

27
Agenda Parallelism
  • Work units organized around activities
  • Processes masters and workers

Master
Workers
Write a Comment
User Comments (0)
About PowerShow.com