1 / 52

Building Good Components for Jaguar CTS 2.0: A Case Study

Building Good Components for Jaguar CTS 2.0: A Case Study. David Lance Wolf Product Line Specialist Jaguar Product Team dwolf@sybase.com news://forums.sybase.com/powersoft.public.jaguar.cts. Sybase Virtual University (or how to double my bonus).

Download Presentation

Building Good Components for Jaguar CTS 2.0: A Case Study

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building Good Components for Jaguar CTS 2.0:A Case Study David Lance Wolf Product Line Specialist Jaguar Product Team dwolf@sybase.com news://forums.sybase.com/powersoft.public.jaguar.cts

  2. Sybase Virtual University(or how to double my bonus) • SVU wants to take over the distributed education market • To demonstrate leadership in this market, they must deploy a successful distributed application • My developers are students!!!! • My bonus will double when the product ships!

  3. Betting My Bonus on Enterprise Application Server • EAS answers the difficulties of robust, scalable and predictable OLTP on the web • Predictable Workloads • Open Standards • Cross Platform • Scalable • Language independent

  4. A little vocabulary! • N-tier computing meant learning a little new vocabulary: • Package • Component • Implementation • Skeleton • Stub

  5. Overview Overview of Component Based Computing Designing The Application Connection Management Transaction Management Component Lifecycles Scalability

  6. What Are Components? • Components are pre-built stand alone ‘pieces’ of a larger application. • Ease development by encapsulating complex, reusable logic. • Components are designed to ‘plug’ together in endless combinations to build larger applications with minimal coding.

  7. Existing component models • Microsoft • COM • DCOM • ActiveX • Object Modeling Group • CORBA • JavaSoft • JavaBeans • Enterprise JavaBeans

  8. Think Components Not Applications • Plan applications and development around “components” rather than processes. • Modeling tools • Riverton’s HOW • Rational’s ROSE • Merging component development with RAD development • Separate layers • Define Interfaces

  9. Overview Overview of Component Based Computing Designing Your Application Connection Management Transaction Management Component Lifecycles Scalability

  10. You didn’t just say my programmers are our students did you? • Students are specialized in their studies • GUI specialty • DBA’s • Java Programmers • C++ Programmers • COM Programmers • I’ll have to divide and conquer to meet my deadline

  11. Separate Business, Data and Presentation Layers Presentation Business Rules Data Access • When “Thinking Components” understand the “layers” of the application • Build components in these layers • Allows reuse of components by choosing layer deployment • Separation of layers allows each layer to live where it is most optimized

  12. Data Access Layer Data Access • How, Where, When of data access • Allows for abstraction of data access methods, from the underlying data store • Often done with procedures, can be extended into components as well

  13. Business Rules Layer Business Rules • Allows for abstraction of the Business Rules, from the Data, and the Presentation • Rapidly change Business Rules, without affecting deployed applications

  14. Presentation Layer Presentation • Leaves final Presentation of the Data and the Rules to the application. • Allows for a Model/Controller/View design • Removes developers from needing to understand business processes, data location, and transactional boundries

  15. Monolithic Computing Presentation Business Rules Data Access • All three layers live in one location • Advantages • Maintainability • Predictability • Disadvantages • Closed System • Poor use of computing resources Server

  16. Client / Server Presentation Client Business Rules Data Access Server • Separates processing across a client and a server machine • Presentation and business logic live on the client • Advantages • Takes advantage of client resources • Disadvantages • Maintenance • Client Programmers need database and logic

  17. Distributed Computing Client Presentation Business Rules CTS Data Access Data Access Server • Separate all three layers • Best use of computing resources • Increases scalability while decreasing system maintenance • Advantages • Scalability • Maintainability • Use of Resources • Disadvantages • Knowledge ramp up time (Integrated Builder Tools!)

  18. Example

  19. Divide and conquer • I can keep my specialized developers working within their area of expertise • I can gain real reusability, even if my programmers graduate • I can maintain this

  20. Overview Overview of Component Based Computing Designing Your Application Connection Management Transaction Management Component Lifecycles Scalability

  21. You only bought a 10 user connection license? • The University has an ASE Server, but they only bought a 10 connection license! • Students use patterns are very unpredictable • The system must be available 24/7 • They need to be able to connect to any database they might buy in the future

  22. Connection and Cache Management • Jaguar 2.0 includes connection pooling via connection caches • Increase scalability via finite connections • Three connection options • WAIT • FORCE • NOWAIT • Three connection pool types • ODBC • OpenClient • JDBC

  23. Connection Options • JCM_WAIT • Causes the component to block until a connection becomes available. • JCM_FORCE • Force a new connection to be built and added to the cache • JCM_NOWAIT • Throw an exception to the calling thread informing it no connections are available

  24. Connection Types • JDBC • Use any JDBC driver available in the CLASSPATH • Only Java components can use a JDBC cache • ODBC • Use a System Data Source Name which is installed by the ODBC Driver Manager • Can be accessed by • C/C++ • ActiveX • Java (via the JDBC/ODBC bridge) • OpenClient • C/C++

  25. Example

  26. Connection Caches! • Connection caching provides a predictable workload on the database • Uses each connection to its fullest • Open design pattern. I can connect to any JDBC, ODBC or OpenClient source. I’d say that’ll cover it!

  27. Overview Overview of Component Based Computing Designing Your Application Connection Management Transaction Management Component Lifecycles Scalability

  28. My GUI developers don’t know a transaction from a tab control! • Seems ‘Introduction to RDBMS’ wasn’t in the GUI specialties required courses (who knew). • I just don’t have time to ramp up these developers • I’m dealing with financial data, I cant afford a mistake

  29. Transactional Components • Declarative Transactions • completeWork • rollbackWork • continueWork • disallowCommit * • Carry Transactions across Components • Must use stubs • Same process space • Can’t carry Transactions across Servers • Client notification • CORBA User Defined Exceptions

  30. Transaction Manager InterfacesObject Context (MTS), Instance Context (EJB) • completeWork() • Vote for commit and deactivate on return • rollbackWork() • Vote for rollback and deactivate on return • continueWork() • Vote for commit and maintain state • disableCommit()* • Vote for rollback and maintain state • inTransaction() • Returns true if the component is within a transaction • isRollbackOnly() • Returns true if the transaction is doomed

  31. Using the Right Transaction Models • Several Transactional Models • Not Supported • Supported • Requires • Requires New • Jaguar opens a transaction on your behalf • Transactional Coordinators • Shared Connection • Microsoft DTC

  32. Transaction Manager Property Definition • Required • If the caller does not have a transaction then a new transaction is started. Otherwise the caller’s transaction is inherited. • Not Supported • If the caller has a transaction then it is suspended and later resumed when the method invocation returns. • Supported • If the caller has a transaction then it is inherited. Otherwise the method is executed without a transaction. • Requires New • If the caller has a transaction then it is suspended. A new transaction is started with this component as its root.

  33. Example

  34. Implicit Transactions • My GUI developers don’t have to worry about transactions • My RDBMS developers can encapsulate this • I can gain reuse from my components by using declarative transactions

  35. Overview Overview of Component Based Computing Designing Your Application Connection Management Transaction Management Component Lifecycles Scalability

  36. Keeping the Professors Happy too?? • Dr. Theory has asked that we reuse some of the code his students used in his “Good State Machines” course • The code wasn’t written explicitly for Jaguar • I need to be able to integrate this code to use transactions, and control state

  37. Stateful/Stateless Instantiation Activation Method Invocation Deactivation Destruction • Component Life Cycle • Stateful Components • Hold state in instance members • Destroyed after use • Stateless Components • Hold no state in instance members • If pooled, after deactivation reenters activation on next method invocation • Can service many stubs instances

  38. Instance Pooling Instantiation Activation Method Invocation Deactivation • Same component instance can re-enter Activate after Deactivation • Components advertise their interest in instance pooling • One component instance can service many client instances • Scalability

  39. Making Your Components Poolable try { rs = stmt.execute(sql); trs = IDL.getResultSet(rs); rs.close(); rs = null; state.completeWork(); return trs; } catch(SQLException sqle) { state.rollbackWork(); } } public boolean canReuse() { return true; } • Return true from canReuse() • Store NO stateful data in instance members • Can store in the database • Can store in a Service component • Can store in a file • Set transactional primitives at method exit • Don’t forget to set primitives in catch() blocks too!

  40. Automatic Transaction Demarcation Instantiation • Useful for pre-built components • Jaguar will deactivate the component at the completion of each method invocation • Synonomous with calling completeWork() or rollbackWork() at each method exit Activation Method Invocation Deactivation Destruction

  41. Example

  42. Lifecycles • Property sheet configuration lets me set state and instance pooling without changing their code • I can now leverage Jaguar performance and scalability

  43. Overview Overview of Component Based Computing Designing Your Application Connection Management Transaction Management Component Lifecycles Scalability

  44. Tell me that student didn’t just say “What does thread safe mean?” • I need to create a scalable application • My developers have NO experience in creating multi-threaded applications • The university has thousands of students across the world, how do I support that kind of load?

  45. Scalability • Jaguar provides a very scalable container thanks to • Early Deactivation • Automatic Demarcation • Instance Pooling • Connection Caches • Service Components • Threading Models • Shared • Poolable

  46. Service Components • Service Components boot at engine start. • Should be Thread Safe for best scalability • Can be used to perform “service level tasks” • Can be used to cache data • Component connects to data source at boot and extracts data • Same instance services all stubs • Refresh data at intervals

  47. Available Threading Models • Concurrency • Multiple invocations processed concurrently • Bind Thread • Allows for thread-local storage • Pooling • Instance pooling • Sharing • Single instance services all clients

  48. Being Thread Safe & Scalable • Try to store state in non-instance member stores • Database • Files • Service Components • Consider using shared container objects as shared objects • Vectors • Hashtables • Make sure when pooling, that instance data is cleaned up in the deactivate stage.

  49. Avoiding Memory Leaks • JDBC • Close Statement’s • Set Statements to null • Close ResultSet’s • General • Clean up in finalizers • set object references to null • Close all streams • Sockets • Files • Objects • Server-Side debugging

  50. Jaguar provides me everything that makes writing servers hard! • Instance pooling, Connection Caching, and Service components let me build a very scalable server • I can have Jaguar do all my thread Synchronization • I can simply configure a components threading models from the property sheets

More Related