INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent...

26
INF5040 (Open Distributed Systems) Lucas Provensi ([email protected] ) Department of Informatics University of Oslo September 13, 2010

Transcript of INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent...

Page 1: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

INF5040 (Open Distributed Systems)

Lucas Provensi ([email protected])

Department of InformaticsUniversity of Oslo

September 13, 2010

Page 2: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Features of Distributed Systems Java EE Architecture Enterprise Java Beans (EJB) J2EE Application Servers◦ Jboss

Example

2INF5040 - Group Meetings

Page 3: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Remote Method Invocation◦ Java RMI

Load Balancing Transparent failover Integration to legacy systems Transactions Clustering◦ State replication across servers

Resource pooling◦ Grouping together resources

Security …..

3INF5040 - Group Meetings

Page 4: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Middleware services provides those features Goal: To separate these concerns from the

application logic.◦ Business logic is more important for developers

Too costly to build from scratch Distributed apps should be portable across

middleware service providers

4INF5040 - Group Meetings

Page 5: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

"The Java Platform Enterprise Edition reduces the cost and complexity of developing ... multi‐tier services, resulting in services that can be rapidly deployed and easily enhanced“

Introduced in June, 1999

5INF5040 - Group Meetings

Page 6: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Distributed multitiered application model for enterprise applications.

6INF5040 - Group Meetings

Page 7: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

A web client consists of two parts: ◦ Dynamic web pages containing various types of

markup language (HTML, XML, and so on), which are generated by web components running in the web tier, and ◦ A web browser, which renders the pages received

from the server. Sometimes called a thin client◦ Usually do not query databases, execute complex

business rules, or connect to legacy applications

7INF5040 - Group Meetings

Page 8: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

The client communicates with the business tier running on the server either directly or by going through JSP pages or servlets running in the web tier.

8INF5040 - Group Meetings

Page 9: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Business code is logic that solves the needs of a particular business domain◦ Receives data from clients, processes it (if necessary),

and sends it to the enterprise information system tier for storage

9INF5040 - Group Meetings

Page 10: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

A server‐side software component model for distributed enterprise applications

Core of the Java EE technology Goal: To provide a standard way to manage

distribution issues in enterprise applications through reusable code◦ By implementing the back‐end 'business' code

typically to enterprise applications◦ Addressing the same types of problems through the

same code

10INF5040 - Group Meetings

Page 11: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

11INF5040 - Group Meetings

EJB

Entity Bean(persistent)

Session Bean(non-persistent)

Stateful StatelessContainer Managed

Persistence

Bean Managed

Persistence

Page 12: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

12INF5040 - Group Meetings

EJB

Message Driven Bean

(non-persistent)Session Bean

(non-persistent)

Stateful Stateless

JPA

Persistent Entities

Page 13: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Entity Beans (deprecated)◦ Now JPA Entity◦ Represent persistent business Entity◦ Persist in storage system ( usually Database)

JPA Entity represents a table in a relational database, and each entity instance corresponds to a row in that table ◦ The class must be annotated with the

javax.persistence.Entity annotation;◦ Entities are managed by one entity manager.

13INF5040 - Group Meetings

Page 14: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Session Beans◦ Perform work for individual clients on the server◦ Encapsulate complex business logic◦ Can coordinate transactional work on multiple

entity beans Session beans can be◦ Stateless‐The SBs belong to the client for duration

of the method call only◦ Stateful‐The SBs belong to the client for duration of

client lifetime

14INF5040 - Group Meetings

Page 15: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Message driven beans◦ Business objects whose execution is triggered by

messages instead of by method calls;◦ Receive messages asynchronously.

The Message Driven Bean is used among others to provide a high level ease-of-use abstraction for the lower level JMS (Java Message Service) specification.

It may subscribe to JMS message queues or message topics, which are typically injected into the bean.

15INF5040 - Group Meetings

Page 16: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Industry standard◦ Vendors design containers to EJB specs

Portability possible across containers◦ The application assembler can build new

applications from existing beans. RAD ability because of the services provided

by container◦ The EJB container, rather than the bean developer,

is responsible for system-level services such as transaction management and security authorization.

16INF5040 - Group Meetings

Page 17: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Rarely necessary for web‐based applications Spring, a lightweight container, can achieve most

of the EJB services◦ makes it easy to use many different services and

frameworks◦ accepts any Java bean instead of specific components

Complexity◦ Specifications were getting more complex◦ EJB 3.0 tries to address this issue

Difficulty in Unit testing◦ If anything goes wrong, is it container related or app

related?

17INF5040 - Group Meetings

Page 18: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Definition◦ Is a software framework dedicated to the efficient

execution of n‐tiered web applications.

Java EE Application Server. ◦ A software package that implements all of the Java

EE APIs and frameworks that allow you to deliver Java EE applications.

18INF5040 - Group Meetings

Page 19: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Connectivity to various applications and DBs on various operating environments and hardware

Provides an integrated IDE for all aspects Support for reusable distributed components

(CORBA, COM, EJB) Performance management (load balancing,

caching, monitoring) Robust and reliable software –redundancy,

backup/recovery User‐friendly administrative, diagnostic tools Strong security framework

19INF5040 - Group Meetings

Page 20: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

A Java EE Application Server provides (at a minimum):◦ Servlet engine/container◦ EJB engine/container◦ Web Server (or ability to integrate with a web server)◦ Concrete implementations of all the J2EE APIs Java Mail Messaging RMI etc.

A vendor‐bought App Server will have additional functionalities

20INF5040 - Group Meetings

Page 21: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Full Java EE App Servers:◦ Apache Geronimo (Apache Software Foundation) ◦ Glassfish Application Server (Oracle Corporation)◦ Caucho Resin Application Server ◦ WebSphere Application Server ◦ JBoss (Red Hat) ◦ Jetty (Eclipse Foundation) ◦ JRun (Adobe Systems)◦ WebLogic Server (Oracle)

Others◦ Tomcat (servlet only)

21INF5040 - Group Meetings

Page 22: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Introduced in 1999 The product of an Open Source developer

community dedicated to developing the best J2EE‐compliant application server in the market

With 1000 developers worldwide and a steadily growing number of downloads per month, reaching 72,000 for October ’01 (per independent www.sourceforge.net), Jboss is arguably the most downloaded application server in the world today

Distributed under an LGPL license, Jboss is absolutely FREE for use.

22INF5040 - Group Meetings

Page 23: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

JBoss 4.0 is compliant to the Java EE specification. So Java EE components such as EJBs can be reused even if they were developed for other application servers

It also supports Java EE Web Services and Service Oriented Architecture

Since JBoss is java based, it can be used on any operating system that supports java

JBoss requires smaller memory than some other application servers and is considerablly faster

It has a very powerful documentation on its web page

23INF5040 - Group Meetings

Page 24: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Some Features◦ Clustering◦ Failover (including sessions)◦ Load balancing◦ Distributed caching (using JBoss Cache, a standalone product)◦ Distributed deployment (farming)◦ Aspect-Oriented Programming (AOP) support◦ JSP/Servlet 2.1/2.5 (Tomcat)◦ JavaServer Faces 1.2 (Mojarra)◦ Enterprise Java Beans versions 3 and 2.1◦ JNDI (Java Naming and Directory Interface)◦ Hibernate-integration (for persistence programming: JPA)◦ JDBC◦ JTA (Java Transaction API)◦ Etc.

24INF5040 - Group Meetings

Page 25: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

Using Eclipse IDE for Java EE Downloading JBoss and integrating with

eclipse Sample EJB Application◦ Creating a Session Bean◦ Execution using JBoss

25INF5040 - Group Meetings

Page 26: INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent failover Integration to legacy systems Transactions Clustering State replication

1. Create a EJB project1. Create a Session Bean and define its business

methods2. Create a Servlet that uses the Session Bean

1. Use the @EJB annotation to create a container managed bean

2. Use the doGet() method to interact with the bean3. Package the application in a EAR(Enterprise

Archive) file4. Deploy the application in the JBoss server

26INF5040 - Group Meetings