• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/51

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

51 Cards in this Set

  • Front
  • Back

Describe and compare three basic architectures of distributed applications. Explain advantages and disadvantages of each of the architectures compared to others.

* Two-tier (Client, Server)


+ commonly used


- Portability


- Network traffic, slow


- Security


* Three-tier (GUI, Business, DB)


+ Skill Partitioning


+ Faster, only GUI is downloaded


+ Security managed in business layer


- More complex, still single point of failure


* P2P (overlay, structured, unstructured)


+ No single point of failure


+ Scalable


- Complex


* SOA (web service based)


+ Standardised

Give a definition of a network socket and a port. Describe major parameters of a socket. Explain the differences between a TCP socket and a UDP socket. Give examples of a distributed application using TCP sockets and an application using UDP sockets. Foreach example, give motivations for use of a specific transport protocol (TCP or UDP)

* Socket is an end-point of a virtual network connection between processes.


* Port is an entry point to a process that resides on a host.


* Connectionless vs. connection-oriented, datagram-based vs. stream-based, unordered vs. ordered, low-overhead vs. complex


* UDP: DNS (small data), streaming (no-retransmit), games (low-latency)


* TCP: file-transfer, HTTP, email (all: lot of data, ordering relevant)

Explain in which cases and why, in a distributed client-server application, both a client and a server should be multithreaded, and what each of the threads should be doing. How threads in the client interact with each other.

Client:


* Why: GUI must be responsive


* UI thread: update GUI


* Worker thread: long running background tasks




Server:


* Why: scalability: handle multiple clients at the same time


* Main thread: accepts connections, spawns workers


* Worker thread: server request to client

Objects of which Java SE classes are needed to communicate using TCP? Explain also what each of those objects represents and what each of those objects is used for.

* Socket: create connection


* Server Socket: wait for incoming connection


* InetAddress: IPv4 or IPv6 IP-address

How do you specify a destination when sending a DatagramPacket object in a distributed Java application using UDP sockets? Upon receiving a DatagramPacket, how can you obtain a source of the datagram?

From DatagramPacket instance methods:


* void setAddress(InetAddress iaddr)


* InetAddress getAddress()




* Alternatively: CTOR instead of setter


* NB: DatagramSocket.send(DatagramPacket p) and receive(DatagramPacket p)

Explain similarities and differences between communication using JMS (Java Message Service) and communication using UDP sockets in a distributed application in Java. Give an example of a JMS-based application and an example of a UDP-based application.

Similarities


* Message Passing


Differences:


* JMS is time-uncoupled, indirect (3rd party: queue), reliable, sender only knows broker address


Applications examples:


* JMS: Notification service, message bus


* UDP: Multiplayer game

Describe steps performed by a client, and steps performed by a server, in order to communicate with each other using TCP sockets in Java. Indicate objects of which classes are used at each step. (Minor errors in class names will not affect your result).

Server:


1. Create ServerSocket instance and bind (some CTORs implicitly bind)


2. In a loop-call accept on ServerSocket


3a. Spawn worker


3b. Handle request


3c. Close Socket




Client:


1. Create Socket instance and connect (some CTOR implicitly connect)


3a. Communicate


3b. Close

Describe steps performed by a client, and steps performed by a server, in order to communicate with each other using UDP sockets in Java. Indicate objects of which classes are used at each step. (Minor errors in class names will not affect your result).

Server:


1. Create Receive Buffer


byte b[] = new byte[256];


DatagramPacket dp = new DatagramPacket(b,b.length);


2. Create DatagramSocket


3. Call receive on DatagramSocket passing Buffer




Client:


1. Create Send Buffer (populate, set dest)


2. Create DatagramSocket


3. Call send on DatagramSocket passing Buffer

Name and explain the meaning of three options (apart from IP address and port number)that can be set for a TCP socket in Java SE. For each of the options, give an example of adistributed application in which setting of the option to a specific value is important.Explain why it is important.

setReuseAddress: Enabling allows the socket to be bound even though a previous connection is in a timeout state.


setKeepAlive: automatically sends a keep-alive probe to the peer after long time of inactivity


setSoLinger: enable gracefully close


setReceiveBufferSize: hint the size of the underlying buffers


setSendBufferSize: hint the size of the underlying buffers


setSoTimeout: Set timeout for blocking operations


setTcpNoDelay: Written data to the network is not buffered.


Backlog: Number of connections backlogged by server.


setTrafficClass: sets traffic class (IP)


setOOBInline: receive urgent data, default: discard

Explain what objects of the following classes (of the java.net package) represent and that they are used for: URL, URLConnection, URLStreamHandler, and ContentHandler.

URL: URL - UniformResource Locator of a Web resource (service)


URLConnection: Represents a communication link to the resource (url.openConnection();).


URLStreamHandler: Knows how to make aconnection for a particular protocol type, such as http,ftp. (factory of URLConnection)


ContentHandler: A ContentHandler has a getContent method that reads data from the input stream of the given URL connection and converts it into a Java object. The handler is associated with one or several MIME types that it can handle.

Describe at least four programming concepts defined and used in JMS.

* Connection factory: encapsulates a set of connection configuration parameters
* Connection: A Connection object is a client's active connection to its JMS provider. It typically allocates provider resources outside the Java virtual machine (JV...

* Connection factory: encapsulates a set of connection configuration parameters


* Connection: A Connection object is a client's active connection to its JMS provider. It typically allocates provider resources outside the Java virtual machine (JVM).Connections support concurrent use. Crease one or more sessions.


* Session: A Session object is a single-threaded context for producing and consuming messages. Although it may allocate provider resources outside the Java virtual machine (JVM), it is considered a lightweight JMS object. It is a factory for its message producers and consumers.


* Destinations (queues, topics): A Destination object encapsulates a provider-specific address. Supertype of: Queue, Topic


* Message producers: A client uses a MessageProducer object to send messages to a destination.


* Message listeners: is used to receive asynchronously delivered messages.


* Message selectors: Filter messages


* Messages:


- Header: identify and route


-Properties: Optional


- Body: Optional



Assume a Java application, in which a client downloads a file from a server using TCP socket connection. Describe steps performed by the client and steps performed by the server to download the file. Indicate objects of which Java classes are used at each step and what do they represent. (Minor errors in class names will not affect your result).

Server:


1. Open ServerSocket


2. In a loop: Accept clients (obtaining a Socket instance)


2a. Write file to client socket (using FileInputStream and OutputStream). Loop until data is written.


2b. Close Socket.




Client:


1. Create Socket instance


2. In a loop: Read from Socket's InputStream and write to FileOutputStream.


3. Close Socket (and all streams).

Give and explain at least two reasons that can motivate a programmer to use the JMS (Java Message Service) API instead of the UDP socket API of the java.net package in a distributed Java application; give an example of such application. Give and explain at least two reasons that can motivate a programmer to use the UDP socket API rather than the JMS API in a distributed Java application; give an example of such application.

JMS:


* Use when: time uncoupling necessary, reliable communication is necessary


* JMS notification server, queue,




UDP:


* Use when: low latency required, ordering, lost packages not important


* Streaming, Gaming

Give a definition of Remote Method Invocation.

Definition: RMI is the object oriented equivalent to RPC (Remote procedure call). The Java Remote Method Invocation (RMI) system allows an object running in one Java Virtual Machine (VM) to invoke methods on an object running in another Java VM.

Explain four different ways, in which an RMI-based Java application executing in one JVM can obtain references to remote objects in another JVM.

* Through a naming service


* As a parameter or a return in remote method invocation


* As an interoperable object reference


* 4?

Name any three RMI-related classes or/and interfaces used in an RMI-based Javaapplication; explain what each of them represents, and what each of them is used for.

* Remote: marker interface: methods may be invoked remotely


* RemoteException: superclass for a number of communication-related RMI exceptions.


* UniCastRemoteObject: Superclass for exporting a Remote object.


* Naming: RMI Naming Service client


* Serializable: Objects passed by value

Give at least two reasons that can motivate a programmer to use RMI instead of plain sockets in a distributed application; give an example of an application using RMI.

* RMI is higher level and abstract many lower level issues for the programmer. For example: call-backs are easy to implement in RMI. (multithreading, distributed garbage collection, object marshalling)


* Location transparency: invoke a method on a stub like on a local object (via stack)


* RMI integrates with Object Oriented Programming.


* Example: A distributed application that makes use of call backs.

Give at least two reasons that can motivate a programmer to use plain sockets rather than RMI in a distributed application; given an example of an application using sockets.

* Low level, compatibility


* Low-overhead


* Example: Embedded devices

Describe what happens when an RMIcall is made. You should describe actions that happen in the call on the way from an RMIclient (the caller) to a remote object in an RMI server (the callee).

Example: r = a.m(x);




Client:


1. Marshal x


2. Send Msg with a, m, x




Server:


3. Recv Msg


4. Unmarshal x


5. result = a.m(x) (Upcall)


6. Marshal result


7. Send Msg with result




Client:


8. Recv Msg with result


9. Unmarshal result


10. Return result

Explain meaning of each of the following JDBC programming concepts and explain what each of the concepts is used for: Data Source, Connection, Statement, Result Set.




Additionally: JDBC Driver, Driver Manager, PreparedStatement

Data Source: Database, a file system, a CSV file. Pointed to by an URL.


Connection: A session with a data source


Statement: For sending SQL statements to the data source. Created from Connection object (SQL envelope)


Result Set: table of data representing a database result set.




JDBC Driver: Object that opens connection to a data source and handles the connection.


Driver Manager: Parses URL of a data source, look for a driver to handle the source, returns a Connection object


PreparedStatement: Represents a precompiled SQL statement prepared using the Connection object.

Explain meaning of each of the following four JPA programming concepts and what eachof the concepts is used for: Entity, Entity Manager, Persistence Unit, Primary Key.




Additionally: Context

Entity: A java class that is mapped to one (or more) tables in a database.
Entity Manager: An interface that defines the methods used to interact with the context, for example create, remove and find.
Persistence Unit: Defines the entities tha...

Entity: A java class that is mapped to one (or more) tables in a database.


Entity Manager: An interface that defines the methods used to interact with the context, for example create, remove and find.


Persistence Unit: Defines the entities that are managed by an entity manager. Defines where to store the entities persistently.


Primary Key: Identifies an entity instance, must be unique for each instance.




Context: The set of managed entity instances within an entity manager at any given time is called its persistence context. Only one Java instance with the same persistent identity may exist in a persistence context at any time.

Explain differences and similarities between JDBC and JPA.

JPA:


+ Persists Java objects, no need to write SQL


+ Complete object graphs


+ Object/relational (O/R) mapping


+ Underlying DB is abstracted away


+ JDBC based




JDBC:


+ Interface to access database


+ Execute SQL commands


+ Underlying DB visible

Give a definition of transactions. What are transactions used for?

Transaction is a group of operations that are ACID:


* Atomic


* Consistent


* Isolated


* Durable




Allow parallel execution of queries, but still guarantee the ACID properties. I.e. no dirty reads, lost updates etc.

Give a definition of Java Servlets. What they are used for? References to which objects are passed to the servlet by the servlet container when it receives a request directed to the servlet? What the objects are used for?

Definition and Usage: A servlet is a component (small Java program) that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP.


Servlet implementations enable a Java EE Web Server to support a particular protocol. In this way, the Web Sever takes care of aspects such as security, parallelism etc.




service(ServletRequest req, ServletResponse res)

Give a definition of Enterprise JavaBeans (EJBs). Describe all different types of EJBs.For each EJB type, give an example of an application, in which this type is appropriate touse.

Definition: a server-side components that exposes methods for performing application logic.




Session Beans (@Stateless and @Stateful): Business process objects


Message-driven Beans: acts as listener in JMS


Entity Beans: depreciate




Example Usage:


@Stateless: Currency Converter Web App


@Stateful: Shopping Cart Web Application


Message-driven: Asynchronous calls


Entity Beans: Use JPA instead.

Explain all actions taken by the JSF (Java Server Faces) container when it processes aJSF page, starting from the time when a client (browser) sends a request to the web serverwith the JSF container till the time when a new JSF page is sent to the requesting client.

1. Restore View
2. Apply Request Parameter
3. Process Validations
4. Update Model Values
5. Invoke Application
6. Render Response

1. Restore View


2. Apply Request Parameter


3. Process Validations


4. Update Model Values


5. Invoke Application


6. Render Response

(True/False/Depends)




Transactions are managed (initiated and committed/aborted) transparently to anapplication using JPA.

True, if used in Java EE. In java SE, use Application-Managed Transactions.

(True/False/Depends)




For security reasons, an applet is allowed to communicate only with a process on that computer, from which the applet has been loaded.

True, if applet runs in a sandbox.




Applets that are signed by a certificate from a recognized certificate authority can either run only in the sandbox, or can request permission to run outside the sandbox.

(True/False/Depends)




It is not necessary to join a multicast group in order to send data to the group.

True

(True/False/Depends)




A session EJB spans multiple client requests and retains state on behalf of the individual client.

True, if it is a @Stateful EJB.

(True/False/Depends)




A reference to a remote object in an RMI-based application can be obtained only by using rmiregistry.

Wrong. There are other ways:


* As a return or parameter.


* As an interoperable object reference


* ?

(True/False/Depends)




A remote copy of an object passed by value as a parameter in a Java RMI call is kept consistent with the original object.

Wrong. It is completely detached from the original object.

(True/False/Depends)




Communication using a socket is stream-based and connection-oriented.

Depends, only if it is a TCP Socket.

(True/False/Depends)




A void remote method invocation is asynchronous and returns as soon as the call is sent to the remote object.

False, could still return a exception.

Communication using UDP sockets is connectionless and stream-based.

Wrong, not stream based.

In JMS (Java Message Service), topics are used for point-to-point messaging; whereas queues are used for publish/subscribe one-to-many (many-to-many) messaging.

Wrong, other way around.

To communicate using a socket, an application has to establish a connection to a remote socket identified by a remote IP address and port number.

True

The persistent state of a JPA entity is represented through persistent properties or persistent fields.

True

Two sockets can be bound to the same local port on the same network interface.

Wrong

For a point-point communication using the Java Message Service (JMS), a message producer has to establish connection to a message consumer.

Wrong, only connects to the message broker.

All entities in the same container share an underlying table in a relational database, and each of the instances of those entities corresponds to a row in that table.

Plain wrong.

What is the difference between a JavaBean and an EJB?

Java bean is just a set of conventions. EJB is a standard for J2EE business components. EJB, despite the name, is almost completely unrelated.

Define Process and Thread

Process: A unit of activity characterised by a sequence of instructions, current state and a set of system resources.


Thread: A path of execution, characterised by execution state, stack and local variables.

Which class is used for Multicasting in Java?

MulticastSocket is a subclass ofDatagramSocket that represents a UDPsocket with capabilities for joining multicastgroups on the Internet.

NIO Motivation

* non-blocking scalable I/O


* allows improving performance

Define: NIO channels,buffers and selectors

Channel: connections to I/O entities, e.g. pipes, files and sockets


Buffer: Containers for data, can be written/read to/from a channel


Selector: Used to select channels ready for I/O (multiplexed, non-blocking I/O facility)

Define RMI Stub/Skeleton.

* Stub: is a proxy for the real object on the client


* Skeleton: is on the server: receives,unmarshalsparameters, calls original routine on the real object (servant)

What is Interface Definition Language (IDL) used for?

Describe interface for RMI (when using CORBA). Stubs and Skeletons can be generated from IDL definitions.

JavaMail Programming Concepts: Session, Message, Address, Transport, Store, Folder, Authenticator.

Session: A session configured by a Properties object.


Message: eMai


Address: Sender/receiver email address


Transport: Transport protocol to be used, typically SMTP


Store: Contains many folders.


Folder: -


Authenticator: Holds credentials.

Define: JNDI Programming Concepts: Name, Binding, Context, Initial context, Naming service, Directory service.

Name: A generic name associated with an object or an object reference.


Binding: The association of a name with an object or object reference.


Context: a set of bindings


Initial context: The root context


Naming service: A server that enables binding names to objects and looking up objects by names.


Directory service: A server that provides a collection of named objects with attributes

Motivation for Web-Sockets:

HTTP is:


- Half-duplex


- Verbose


- Polling is inefficient