36
21 September 2006 Kaiser: COMS W4156 Fall 2 006 1 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser [email protected] http://york.cs.columbia.edu/clas ses/cs4156/

21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser [email protected]

Embed Size (px)

Citation preview

Page 1: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 1

COMS W4156: Advanced Software Engineering

Prof. Gail Kaiser

[email protected]

http://york.cs.columbia.edu/classes/cs4156/

Page 2: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 2

COM+

Page 3: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 3

Just-In-Time Activation• Also known as deferred activation• When a client makes a call to an object to create

an instance, COM+ provides that client a reference context (using IObjectContext interface) instead of a reference to the object

• Client gets reference to the object when client calls a method of that object

• Useful if many clients instantiate an object but few actually call its methods

Page 4: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 4

Object Pooling

• Recycling of objects• When a client releases an object that supports

object pooling, instead of destroying that object completely, COM+ recycles it

• When another client requests the same kind of object, COM+ gives an instance from the pool

• Since these component instances are already loaded in memory, they are immediately available for use by client applications

Page 5: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 5

Resource Pooling

• Opening and closing connections to a database can be time-consuming

• Reuse existing database connections rather than create new ones

• A resource dispenser caches resources such as ODBC (Open DataBase Connectivity) connections to a database, allowing components to efficiently reuse them

Page 6: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 6

Role-Based Security

• “Role” = a logically related group of users that share the same permissions to access a defined subset of an application’s functionalities

• Assign different permissions for different roles on a class, interface or method

• Can set either administratively (using COM+ Explorer) or via programming

• Don’t need to write security-related logic into components (but can do so if desired)

Page 7: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 7

Load Balancing

• Scalability: network traffic and number of clients shouldn't affect performance of an application

• Load balancing distributes client calls across server cluster (on business logic tier) transparently to the application

• Components to be load-balanced configured on per-class basis at deployment: check the box in the Component Services Explorer

Page 8: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 8

COM+ Router

• When a client requests a specific component, it first connects to a load balancing router (itself possibly a cluster)

• Router polls the cluster application servers for timing data (by default every 200ms)

• Router chooses a server based on lightest server load and availability

• Modified round-robin algorithm

Page 9: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 9

Service Control Manager

• COM+ router’s SCM forwards the activation request to the selected server's SCM

• If the instantiation of the object fails, the router moves to the next server in the round-robin list

• Continues until a valid interface pointer is returned to the client

• From this point, all communication occurs directly between the client and the server that handled the request

Page 10: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 10

Queued Components

• Client can execute (asynchronous) method calls, even if the server component is offline

• MSMQ (Microsoft Message Queue server) records and stores method calls automatically whenever the server object is available

• Useful for online applications that must be completed (online banking, air reservation system, etc.), mobile users, etc.

Page 11: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 11

Component Availability

• In synchronous processing applications, if just one component of a compound activity is not available—perhaps because of server overload or networking problems—the entire process is blocked and cannot complete

• An application using the COM+ Queued Components service separates the activity into actions that must be completed now and those that can be completed at a later time

Page 12: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 12

Client/Server Decoupling

Page 13: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 13

Message Queuing

• A queue is a storage area that saves messages for later retrieval

• Provides a mechanism for connectionless communication - sender and receiver are not connected directly and communicate only through queues

• COM+ Queued Components service automatically marshals data as messages

Page 14: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 14

Message Reliability

• Message Queuing uses database techniques to help protect data in a robust way

• Built-in support for transactions• In the event of a server failure, Message

Queuing ensures that transactions are rolled back so that messages are not lost and data is not corrupted

Page 15: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 15

Server Scheduling

• An application using queued components is well suited to time-shifted component execution, which defers non-critical work to an off-peak period

• Analogous to traditional batch mode processing• Similar requests can be deferred for contiguous

execution by the server rather than requiring the server to react immediately to a wide variety of requests

Page 16: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 16

Original COM Events

• Choice between two (similar) techniques

– Interface callback mechanism

– Connectable Objects

Page 17: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 17

Interface Callbacks

• Client implements a COM interface described by the event publisher component, and passes a pointer to this interface to the component

• Client then receives notifications (i.e., events or callbacks) when the component calls a method through the interface implemented by the client code

Page 18: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 18

Connectable Objects

• Also known as connection points• Exchange of an interface pointer implemented

by the client (invoked to notify of an event)• Uses COM's standard IConnectionPoint

interface (and 3 related interfaces)• Connect (Advise) and disconnect (Unadvise)• Enumerate connections (EnumConnections)

Page 19: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 19

Example

Page 20: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 20

COM Events Problems

• Only a series of interfaces - developers still have to write the code to implement these interfaces

• Client and component lifetimes are tightly coupled through the exchanged interface pointer - the client must be running and connected to receive events

• It is difficult to get between a component instance and its clients to monitor the connection, provide trace information, etc.

Page 21: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 21

COM+ Events

• Publish-subscribe model rather than request-reply• Publishers are not tightly bound to their

subscribers and in most cases don't even know who they are

• Publishers do not block when firing an event• Subscribers do not bind themselves directly to

publishers - an intermediary object manages communication between a publisher and its subscribers

Page 22: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 22

Event Class

• An event class component sits between a publisher of information and any potential subscribers

• COM+ Events system provides the actual implementation of this intermediate object

• Eliminates the need to directly pass an interface pointer through an Advise method

• Publisher and subscriber lifecycles no longer tightly coupled

Page 23: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 23

Publisher

• The event class looks like a subscriber to the publisher

• When a publisher wants to “fire” an event, it creates an instance of the event class, calls the appropriate method, and then releases the interface (as in queued components)

• The runtime then determines how and when to notify any subscribers

Page 24: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 24

Subscriber

• To receive events, need only implement the event interface

• Registers with the COM+ Events service by creating a subscription object, through the IEventSubscription interface

• The component will be (activated and) notified as events are published

• Either persistent or transient subscriptions

Page 25: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 25

Example

Page 26: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 26

Example

Page 27: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 27

Improved COM+ Events

• Provides a “third-party” publish-subscribe environment: Once an event class is created, anyone can become a publisher or subscriber of the events

• Supports a rich filter mechanism: one can filter at the publisher method level – allows event class object to decide which subscribers receive a particular event, or at the method parameter level – complex criteria string per subscriber

Page 28: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 28

Filtering Example

Page 29: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 29

Individual Development Assignment #2 due Tuesday September 26th

• CORBA-based distributed computing • Implement an AuctionHouse application

(this time you submit the code)• Choose an ORB

– List of free ORBs supporting Java and/or C++ available at http://cmeerw.org/freeorbwatch/

– Warning: the various ORBs support varying versions of the CORBA spec (most supply many more features than discussed in class)

Page 30: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 30

IDA #2

• 3 kinds of components:– Supplier: infinite supply of auction Items– Customer(s): submits bids to the AuctionHouse for a

given Item– AuctionHouse: sells a limited set of Items to

Customers; buys new Items from Supplier• Your implementation must support

– English Auction mode– Bazaar Negotiation mode– Simultaneous interactions with multiple customers– Re-ordering from the Supplier

Page 31: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 31

IDA #2: English Auction• Customers bid against each other for the same

(single) Item within a time limit• Customer requests current price (either initial

price or highest bid so far)• Customer submits bid (same or higher than

initial price, higher than highest bid so far)• Customer can continue placing additional bids• After time limit expires, AuctionHouse does not

accept any more bids for that Item and notifies winning Customer

Page 32: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 32

IDA #2: Bazaar Negotiations• Customer haggles with AuctionHouse to purchase

an Item, independent of other Customers• Customer requests current price (either initial

price or price AuctionHouse has most recently offered to that Customer)

• Customer submits bid (same or lower than initial price, higher than that Customer’s previous bid)

• AuctionHouse accepts bid if the same or higher than minimum price

• Otherwise AuctionHouse replies with a new price (always the same or higher than minimum price)

• Repeat until bid accepted or Customer quits

Page 33: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 33

IDA #2 Deliverable (archive file)

• Source code • Output files (screen shots, traces) showing one

significant system run for each of the modes – Sequence of AuctionHouse activities– Make sure to include interaction with Supplier as well

as with multiple Customers •  1-page README describing your

implementation and instructing on how to compile, install and run it 

• 1-page report on your findings and impressions on CORBA-based distributed computing

Page 34: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 34

Upcoming

• Teams announced September 26th

• Team project concept due October 3rd

• Individual development assignment #3 due October 10th

• Revised project concept due October 17th

Page 35: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 35

Office Hours

• Prof. Kaiser: Tue/Thu 12:30-1:30, 607 CEPSR

• Anurag Chakravarti: Wed/Fri 11-12, 7LW1 CEPSR

Page 36: 21 September 2006Kaiser: COMS W4156 Fall 20061 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser Kaiser+4156@cs.columbia.edu

21 September 2006 Kaiser: COMS W4156 Fall 2006 36

COMS W4156: Advanced Software Engineering

Prof. Gail Kaiser

[email protected]

http://york.cs.columbia.edu/classes/cs4156/