TU Wien:Distributed Systems Technologies VL (Froihofer)/Fragensammlung SS09
Eine Liste möglicher Fragen, ausgearbeitet von einem Studenten. Keine Garantien für Korrektheit und Vollständigkeit, Verbesserungen sind erwünscht(Stand: SS 2009)
Middleware configuration and metadata[Bearbeiten | Quelltext bearbeiten]
How is middleware related to transparency? Makes communication and other features transparent. Business logic and presentation are not mixed with communication code, code to deal with platform specifics etc.
Name a few middleware models and architectural styles
- Everything is a file
- Remote procedure calls
- Event systems(messages)
- Streaming
- Distributed documents(e.g. www)
Which services does middleware usually provide?
- Communication
- Naming
- Security
- Transactions
- Data persistence
What is the difference between explicit and implicit middleware? How can implicit middleware be configured?
- Explicit middleware
- Explicit calls from the business logic to the middleware, e.g. to retrieve the next RPC invocation, parse it, and return the result, configure the middleware.
- Implicit middleware
- Servant is loaded by the middleware, middleware does all its work automatically and just calls the servants method to perform the application's work.
Implicit middleware can be configured via attributes/annotations, or via configuration files in the deployed package.
When can java annotations and .NET attributes be set and read? How can it be read? At which point in the middleware runtime does the middleware usually process this data and why?
- Writing: Compile time
- Read: Compile time, runtime. At runtime they are read via reflection
Middleware usually reads all annotations at initialization time. Lazy init is theoretically possible, but tedious because some settings potentially have to be acted uppon before the class that sets them is used the first time.
What are java classes and class loaders? Java classes are stored (usually) in .class files, which contain immediate language code (later JIT-compiled to native code). A class loader loads the file from disk, and creates a memory image from the class, which can be used to instanciate the class and execute its methods.
Alternatives are possible. Apps can provide class loaders that load a class from a network location for example.
Which class loaders does Java have?
- Bootstap class loader: loads low level classes like java.lang.Object
- Extension class loader: loads classes in the "lib/ext" directory and system specific extension directory
- System class loader: loads classes from the CLASSPATH
Which advantages does support for dynamic class loading offer?
- Necessary to write plugins(see below)
- Class loaders can modify bytecode
- Class loaders can add support for other class file formats, or other locations to load classes from
What are plugins? Pieces of program code that is loaded into a separate program and uses a well-defined interface to extend its functionality. The kind of functionality provided by the plugin is not anticipated during development or compile time of the host application. Example: Web browser plugins like Flash, Eclipse IDE plugins (Eclipse even calls itself a “framework”, a lot of functionality is provided by plugins).
Where does bytecode modification take place? Why is it used? What are the advantages and disadvantage to source code modification? It is done during class loading. It is used for aspect oriented programming, for example: Add logging calls Add code to support dependency injection Insert middleware-specific calls If used well, it can decrease code(source and binary) coupling of middleware and code running in it, thus aiding code maintainability and reusability.
Advantages over source code modification: Source code not needed, no recompile needed Disadvantages: Harder to debug, both the modification, and the modified class because. Only the bytecode can be debugged, as the modification is not visible in the source.
What is dependency injection? Why is it called inversion of control? Which injection methods do you kow? What is injected? Middleware provides resources that the servant needs. The servant would be responsible for retrieving the resources, but instead the middleware takes over the responsibility and provides the servant with them, hence the name “inversion of control”
Reasons:
- Reduce number of explicit middleware calls
- Makes code easier to write
- Allows better code reuse.
Implementation strategies:
- Constructor args: Easy, but scales badly
- Setters: not much harder, but also doesn't scale well
- Reflection: Scales well, no special methods in the servant class needed.
How do reflection-based injection, constructor injection and setter injection work? What are advantages and disadvantages of each of them?
- Constructor:
class foo() { foo(dependency1 dep1, dependency2 dep2) // Q: how many dependencies must be considered? { ... } }
- Setters: Provide setters setting one dependency each. Middleware calls the setters
- Reflection: Middleware uses reflection to write the resource instances to the classes fields. Middleware must know about dest. Fields, e.g. marked with annotations.
What reasons are there for using inversion of control?
- Fewer middleware calls
- Reduces dependency on specific middleware
- Code reusability
- It just looks nicer
Spring framework?
Which bean instantiation modes exist for injected beans (not web app beans).
- Per instance: Create a new instance of the injected bean for each object it is injected into
- Singleton: Create one instance, inject it into every target object.
Middleware Services[Bearbeiten | Quelltext bearbeiten]
Which services does Middleware offer?
- Communication(messages, RPC, streaming)
- Naming
- Persistence
- Transactions
- Replication
- Security
- etc
Explain the difference between explicit and implicit middleware. See above section(“Middleware configuration and metadata”).
What are interceptors? How do they work, and why are they used? How can it be implemented? Hooks that allow requesting that a function be called at an incoming request. Hooks can read, modify or drop the request. Interceptors are offered at different stages in the request processing, and are implemented in the request processing code (for example .NET: Add an additional sink into the request channel)
Interceptors can implement add-on services, like security check. An interceptor could read the request, and if the caller has the necessary permissions, pass it on. Otherwise drop it or return an error.
This allows separation of concerns – security can be implemented in interceptors, and doesn't get mangled with business language code. This separated security code is also easier to reuse.
What are transactions? Provide ACID(atomicidy, concurrency, isolation, durability) criteria for middleware. Any number of operations are grouped together in a transaction, and are either all persisted, or all of them are rolled back.
Explain explicit and implicit transactions.
- Explicit
- Client code, or a servant starts the transaction, makes it current and commits it
- Implicit
- Middleware starts and commits. Used with asynchronous calls when no client code is around to start the transaction.
What is the 2 phase commit? Name the two participants. What are the states of the commit process from their point of view in succeeding and failing commits?
- Participants: Coordinator and one or more resources
- Outcomes: successful commit, or rollback
- Coordinator:
- 1. Send ready-to-commit message to participating resource classes
- 2. If all reply with OK, send commit message. If one replies with not OK, send rollback
- Resources:
- 1. Coordinator sends ready-to-commit message. Reply with OK or NOK
- 2. Rollback order from coordinator: Roll back. Otherwise commit.
If the coordinator crashes before (2) is completed, rollback. If a resource crashes before all messages are in, coordinator requests collback. If a resource crashes after coordinator sends commit or abort message, the resource is responsible for querying the outcome of the (from its POV unfinished) transaction and comply. (It hopefully has the old info stored somewhere)
Name some transaction service implementations. JTA, Corba transactions
Outline explicit transactions from the transaction initiator's point of view in pseudo code.
- 1. Create transaction
- 2. transaction.begin() - makes transaction current
- 3. Perform transactional operations
- 4. transaction.commit(), or rollback()
How are transactions propagated? What is the transaction context? The transaction service propagates the transaction context with invocations, as part of the invocation context. The transaction context contains the active transaction, the initiator and participating objects. Objects can register themselves when they are called with an active transaction and want to be informed about its outcome.
How can server code detect if a transaction is active? A transaction is usually assigned to a thread (in thread local storage) by the middleware. A transaction can be active in multiple threads, but one thread can have only one transaction. Servants can easilly detect if a transaction is active by looking if there's a transaction attached to the thread(using middleware APIs)
Which transaction attributes can a EJB bean set?
- Unsupported: Bean doesn't support transactions. Raises an exception if there is one
- Required: Client is required to provide a transaction. Raises an exception if there is none
- Start_new: Middleware creates a new TX and commits at the end
- Optional: Can support transactions, but doesn't require one
What is the difference between long-running and short-term transactions?
- Short term: Classic transactions, usually only covering a few calls and running for a short period of time
- Long running: Transaction takes too long to lock involved resources → See offline concurrency
Business vs system transactions? Conversations? Conversation write-out options? Compensation action? Side effects in compensation actions?
- Business transaction: Long running transaction, managed via offlince concurrency patterns
- System transaction: A normal short-running transaction. A business TX can spawn multiple system transactions.
Write-out options: Write out as soon as possible Or wait until the business transaction is finished If option 2 is chosen, those writes have to be compensated if the business transaction fails, e.g. by deleting the new entries or reverting entries to the old state. If there were side effects, those may not be compensateable. E.g. an ATM cannot recover money dispensed 10 minutes ago.
What issues with primary keys may occur in long-running transactions? If the transaction is rolled back and objects are deleted, there may be holes in the primary keys. Might not be an issue if it doesn't happen too often Primary keys might need to be assigned before the transaction finishes The system has to watch out that primary key constraints aren't violated by not properly creating primary key before the transaction finishes.
Transactions and persistence context in EJB?
Describe the following security terms: Authentication, Authorization, Access Control, Impersonation.
- Authentication
- Proofing one's identity to the authentication service
- Authorization
- Granting specific permissions to a user (e.g. Create files, access certain services, …)
- Impersonation
- Running code with someone else's credentials and permissions.
- Access control
- Humm
Security Levels: Code Security, Privilege based security, role-based security.
- Code security
- Making sure the code is not modified and is the code it claims to be.
- Privilege based security
- Requiring special privileges for certain actions(e.g. Create files, send network messages) and selectively granting these privileges to Code
- Role-Based security
- Instead of granting privs to code, create roles (for example usernames) which are assigned privileges. Running code inherits these privileges from the user it is running as.
What is the Java security manager? Privilege-based security management (depending on where the code comes from), and code security (signature checking). Java Code has different privileges depending on where it was loaded from(See next question). Privileges are passed on in function calls. If code from a higher privileged source is called by lower privileged code, it doesn't have it's higher privileges except if it explicitly requests them(SecurityManager.doPrivileged())
The security manager checks if the requested actions are permitted. If there is no security manager, the code has all permissions. A security manager can be assigned via SetSecurityManager (but that needs permission of course)
Which Java code is considered trustworthy? Core classes and any code loaded from CLASSPATH
ProtectionDomain? CodeSource? Permission class? Policies?
What is the AccessController? What is a privileged caller?
What issues does the AccessController have to deal with regarding multithreading and events?
What are Java Security Policies?
How is the security for java applets managed?
What is the Java Authentication and Authorization service?
Describe JAAS classes: Subject, Principal, LoginModule, Configuration, LoginContext, CallbackHandler
- Principal
- Identification information, e.g. a username.
- Subject
- Object returned by a successful login process. Has the privileges of the logged in principal.
- LoginModule
- Module performing the actual identification check. Can be a simple username/password check, a smartcard check, etc
- LoginContext
- Main JAAS class. Can create login contexts (based on configuration), call them to do the login.
- CallbackHandler
- Interface implemented by the JAAS client to allow the LoginModule to request information from the user (e.g. write strings, read keyboard input).
Describe the JAAS authentication process.
- 1. Create login context
- 2. Configure login context (e.g. via configuration file). Selects the login module
- 3. Call the login method. Returns a subject object if successful
- 4. Use the subject to execute code.
How can privileges be assigned to principals? Via configuration files. Configuration files can specify roles, principals, and assign roles to principals. Java code can later check if the current subject is in a specific role, either via explicit check, or implicitly via EJB annotations.
EJB security? Annotations and explicit checks can check if the subject that is calling the bean is in the required roles.
Presentation Tier[Bearbeiten | Quelltext bearbeiten]
What are the advantages of web-based user interfaces? No software needed. Pretty much everyone has a browser Platform independent Users know how to work with a website (common ui approach)
What is the difference between a Script-based web program and server pages? Describe both systems. Name examples. Script-based: For example CGI, Java servlets. The script gets the HTTP request and constructs a reply string. Can be written as a normal program, Java class, … writing it is easy, can do everything a normal program can, but hard to maintain. Content and logic usually not separated. Server pages: A page integrated into the webserver. Webserver parses the HTTP request. Not a standalone program, but eases separation of concern. Content/logic separation easier, but not enforced. Code inserted into HTML template.
Describe the Model-View-Controller pattern. Describe the 3 participants. What does the Controller do? Model: The busines logic tier View: Web page / GUI templates without program logic. Can be written by designers without programming knowledge Controller: Small program logic in the presentation. Embeds values returned by the model into pages, processes inputs, calls the model.
What is a page controller? How can it be implemented? How does it fit into the MVC pattern? How is common functionality among many pages handled? It implements the “controller” part of the MVC pattern. It handles input, validates it, calls the model, updates the view. Common functionality can be moved to a front controller which runs before the actual page controller runs. This can be used to implement cross-page features like security checks.
A page controller handles just one page. It's the web server's job to determine the correct page controller, e.g. via URI.
How can Front Controllers be combined with Intercepting filters? Putting common functionality into the front controller directly is not always a good idea. Doesn't separate concerns.
Better to combine this with middleware interceptors to implement separate features in separate interceptors.
What is a Template View, and which technologies employ this pattern? What are the advantages and disadvantages? Suggest some ways to overcome the disadvantages. Separate the graphical content from the program logic finding the patterns.
Advantages: Separates layout from view logic Layout can be edited without programming knowledge (e.g. by a designer) Powerful
Disadvantages: It's still tempting to use flow control constructs in the template for program logic. Without that, the whole thing can be inflexible Move almost all logic into separate scripts/beans/... and call them from the template
Technologies: JSP, PHP, ASP, JSF
What are tags in JSF and how are they used? How should they not be used? Slide 25: I don't really understand the point of this, other than that the tags are XML tags.
What are Web Components? They are templates which can be used for building the website, like GUI components that can be combined for a desktop application. Those components can already support different renderers(e.g. Mobile devices, desktop browsers), thus the layout of the website is automatically adjusted.
What is a Transform view? A view template is transformed into different formats, for example HTML or PDF. Often based on XSLT.
What are Java servlets? Which Presentation Tier pattern do they implement? Name some differences to CGI scripts. What is their input and output? How are they configured? How can they interface with the domain logic? They implement the script based web program pattern. They are java classes that take a HTTP request and generate a reply string. As a normal java program they can access the domain logic like any other java-based client can.
Describe Java Server pages. What do they contain? What pattern do they implement? How are they related to servlets? Page based pattern. They contain a HTML template and certail logic elements (flow control, call to other java classes). They are translated into a java servlet by the JSP webbrowser plugin and run as a servlet.
It's possible to use normal java code ( <% String foo; %> ), simple expressions ( $(foo) ), and tags. Tags are provided by Tag libraries and allow interacting with the HTML environment, server environment, beans, etc. They provide access to Beans, but also other features like control flow, redirects, SQL, XML, Formatting.
How is a request processed in Java Server Faces?
- 1. Restore view: Create / restore object graph
- 2. Apply request values: Send data to UI objects of the view (text fields, etc)
- 3. Validations: Validate input fields
- 4. Update model values
- 5. Invoke application
- 6. Render response
How can JSF pages talk to the business logic? They can access beans that are part of the presentation via normal JSP methods. The beans then verify the request, communicate with the business logic and make the result available via property getters, which are read by the view template.
How can Front Controller be integrated into JSF? Register a bean that implements the FacesServlet interface. All requests routed through this bean.
Navigation rules and events in JSF? Are configured in the deployment descriptor (a XML file). Button presses and similar user interaction leads to events, which are handled by a bean. Depending on the outcome, a new page can be loaded.
What does the term “Rich Internet Applications” mean? What is the goal? Name a few technologies that attempt to provide RIAs. Goal: Make browser based apps like desktop apps in appearance, interactivity and response times, multimedia capabilities.
Examples: AJAX in-browser java applets ActiveX Flash Silverlight
What problems do traditional web pages have that makes them different than desktop apps? Web browser features get lost, e.g. the behavior of the back button may be broken. Often security concerns because the applets run on the client machine and could contain
Depending on the technology: Binary encoded, thus not searchable by search engines. Runtime (JVM u.a.) startup times.
AJAX details? Different than Desktop applications. Supports reloading pages partially. Reduces network traffic, increases responsiveness.
Client-side java script intercepts user actions, asynchronously communicates with the web server and re-renders parts of the website by modifying the DOM tree.
Integration into existing JSF pages via the AJAX tag library.
JavaScript part performs remote communication via the XMLHttpRequest JavaScript object. This even allows web service invocations and allows transfering JSON objects(sounds like a serialized JavaScript object)
What problems does AJAX have?
Message oriented middleware[Bearbeiten | Quelltext bearbeiten]
What is the difference between message oriented middleware and remote procedure calls? RPC hides communication, makes it implicit. Communication looks like a local method call MOM makes communication explicit, via message passing. Network programming issues are still abstracted by the middleware.
What is the difference between transient and persistent communication?
- Transient: Both sender and receiver have to be online at the same time, otherwise messages are lost.
- Persistent: Message channel stores messages when receiver is not connected. Receiver can later read messages even if the sender has disconnected by then. The message is stored in the message system.
What is the difference between synchronous and asynchronous communication?
- Synchronous: Sender blocks while waiting for message delivery (and possibly reply). Common in RPC.
- Async: Message is sent, sender immediately continues with his work. Can later check the result, but this is optional.
Name a few examples for message-queuing systems! E-mail, Classic postal mail
What are the 4 message queuing primitives? Describe them.
- Put: Send a message
- Get: Read a message and remove. Blocks if no message.
- Poll: Read msg if available, but don't wait for one; return instantly with error if no msg
- Notify: Middleware notifies receiver about new msgs.
What is a message broker and what is it used for? Manages message passing and associated issues. Often converts between different Message formats and supports multiple communication systems.
What is JMS and what are its objectives? A java API for message passing that allows integration of different JMS providers which support different communication channels and message formats.
Describe the following JMS definitions: JMS provider, JMS client, non-JMS client, JMS message, JMS domain, Administered objects
- JMS Provider: Implements the underlying message system, e.g. Corba events
- JMS Client: Client using the JMS API
- non-JMS Client: Client not using JMS, but for example the provider's native API, like Corba events
- JMS Message: A message managed by JMS and its providers. (Hmm. Not sure)
- JMS Domain: can be broadly classified as either point-to-point or publish-subscribe system
- Administered Objects: JMS objects configured by an administrator for the use of clients: Connection Factories, destinations.
How is Security handled in JMS? JMS itself doesn't implement any security system, but servants can use message filters to add security checks.
What are the two main parts of a JMS message? Header and Body
What is stored in the message header? Usually information that is needed for message routing. Information not needed for message routing is in the body.
- Message ID
- Timestamp
- Priority
- Delivery mode (once aka persistent or transient)
- Expiration
- ...
There are also optional properties that can be set by the JMS client
What types of information can be stored in the body of a JMS message?
- Strings
- Serializable objects
- Name-value maps
- Uninterpreted bytes
- Java Streams
However, everything can be put into an object or a string, so basically all sort of information can be sent in a message.
What is the difference between a JMS Queue and a JMS Topic? How many senders and receivers are involved?
- Queue
- One receiver receives the message. Multiple senders possible, multiple receivers possible (for spreading load), but one message is received only once
- Topic
- Multiple senders(=publishers) and receiver(=subscribers). A Message is delivered to every subscriber. No order guarantees
What is the difference between ordinary and durable subscribers? What is required for this to work?
- Ordinary
- Messages posted when not connected are lost
- Durable
- Requires a durable topic, and message must be marked durable. Messages that are sent while the subscriber is not connected are stored in permanent storage and delivered on next connect.
When are messages deleted from the JMS system? What happens if a consumer crashes during message processing? They are deleted once they are confirmed by the recipient. A recipient should only confirm once he's done processing it. If a message is delivered twice because the recipient crashed during processing it has a redelivery marker set.
How can messages be filtered using JMS? What is the advantage of that? A subscriber can set filter criteria when subscribing to a topic, with syntax similar to SQL conditions and expressions. The advantage is that JMS can drop the message, and doesn't have to deliver or persist them. Otherwise the message would be delivered (causes load) and dropped afterwards.
What are message driven beans? Enterprise Java Beans that produce or consume messages (either via queue or topic)
Outline the steps needed to write a JMS message producer!
- 1. Create a channel factory
- 2. Open connection
- 3. Create session
- 4. Look up destinations
- 5. Create message producer
- 6. Create a message
- 7. Use the producer to send the message
- 8. Close connection
Which options are available for writing a JMS consumer?
- Implement a listener interface
- Call the blocking messageConsumer.receive() method
- Implement the consumer as a message drive bean
How can a request-reply communication be implemented? Two queues, each participants writes to one queue and reads from another. However, RPC may be a better choice than messages in this case.
What are pipes and filters? Name some other usage examples of this pattern.
- Pipes: “dump” connections between producer, filters and consumers.
- Filters: Provide the application logic of the filter system.
Fairly old pattern, for example used in Unix.
Describe the following patterns and give some usage examples and implementation issues: Splitter, Aggregator, Message Filter, Composed Message Processor, Scatter-Gather, Recipient list, Routing Slip, Dynamic Router, Process manager.
- Splitter
- Breaks up a big message into smaller ones. E.g. an order for 3 items that are forwarded to 3 different companies
- Aggregator
- Collect multiple messages, combine them into one. Inversion of the Splitter pattern. E.g. to collect the 3 invoices from the 3 companies into one invoice sent to the customer
- Router
- Forwards the message to one out of many recipients
- Message Filter
- Drops unwanted messages from channel, passes others
- Composed message processor
- Splitter + Message filter + Aggregator
- Scatter-gather
- One message is duplicated, sent to multiple recipients. Replies are collected, one is forwarded. E.g. bidding for the cheapest offer.
- Recipient list
- Duplicates one message coming from a queue into different queues. See next question
- Composed message processor
- Used if a message contains multiple items that need different processing. Splitter → router → message specific processing → aggregator. E.g. validating a order that consists of multiple suborders.
- Routing Slip
- Send messages through processing steps that aren't known beforehand: Client router adds a routing table to the message. Each service router checks the table, sends the message through processing and then forwards it to the next router. The client router may be the last entry in the routing table to return the message to the client.
- Dynamic router
- Similar to a plain router, but possible recipients send messages about themselves to the router's control channel, stating which messages they can accept. This allows run-time configuration of the router. Conflicts have to be resolved by the router. Drawbacks: Complexity, debugging
- Process manager
- Similar to routing slip, but keeps centralized control over routing. Message is sent back to the process manager after each step.
What is the difference between the recipient list and the publish/subscribe models?
- Recipient List: Message producer picks receivers.
- Publish/subscribe: Receivers have to subscribe themselves
Transformation patterns: Data/Content Enricher, Claim check, Content Filter
- Content enricher
- Additional information is added. E.g. a message contains just a primary key for a class – content enricher fetches the rest of the informaion and attaches the full object to the message
- Claim check
- Parts of the message are stored in the DB. Recipients can fetch the content later with a message ID or similar information left behind in the stripped down message
- Content filter
- Removes parts of the information, e.g. for security reasons
System management patterns: Control Bus, Control Interface, Message Header, Evelope Wrapper/Unwrapper, Message History, Message Store, Test Message
- Envelope wrapper
- Whole message, including header is put into a new message's body, and new routing information is added to the new message's header. Unwrapper unpacks the old message again. E.g. for tunneling a message through a different message system.
- Message history
- Each processing step is recorded in the message. The receiver can then reconstruct the way the message took, similar in the fashion of the traceroute tool for IP routing.
- Message Store
- Captures information about each message in a central place, e.g. a log table in the database.
- Message Header
- Separate message content from control information
- Control bus
- Separate channel transmitting data from/to different parts of the message processing system. E.g. for following test messages, configuration, statistics
- Control interface
- Interface abstraction of a message processing system???
- Test message
- Message that actively tests messaging components. Doesn't rely on information generated by components, but can be used to check if the components behave correctly.
Business logic and data access patterns[Bearbeiten | Quelltext bearbeiten]
What is the difference between Two-Tier and Three-Tier architectures? What are the different tiers?
- 2-Tier: Database, Business logic+Presentation
- 3-Tier: DB, Business Logic, Presentation. Presentation is usually separated from DB
What is the business logic and what does it do? What does it not do? Which layers should or should not depend on which other layers? The business logic contains program code needed to perform the actual work the program is supposed to do. It does NOT store the data manually (instead uses a Database), and it does NOT have a user interface (neither web nor any other UI).
The Presentation layer usually depends on the business logic, but the business logic must not depend on the presentation.
How can the business logic be split further? Can be split further into Domain logic and Application-specific logic.
Name 3 possible business logic structure patterns and describe them. What are their advantages and disadvantages?
- Transaction script
- A script that takes the income and performs SQL queries in the DB manually. Easy to set up for simple tasks, but hard to extend and maintain.
- Table module
- A wrapper around database tables. Hides SQL commands, but still not really object oriented.
- Domain model
- Objects that match single entries in the database. Objects can have methods that perform operations on them etc.
What is the difference between the Domain Model and a database?
- Database
- Just a data store.
- Domain model
- Doesn't store data itself (uses DB), and offers program logic to work with the data. Also relational database vs object oriented way of thinking, thus features like inheritance are available.
What is the difference between a Table Module and the Domain Model?
- Table module
- Just data access in an object oriented way, but usually little programming logic. One object for one table.
- Domain model
- Object per table entry with business methods etc.
What is the goal of all data source patterns? Hide the SQL. (Hmm. Not sure)
Name 3 data source patterns and describe them. How do they fit into the business logic patterns?
- Row data gateway
- A class which can search for and return one line from the table
- Table data gateway
- Gives access to an entire table. Fits well into transaction script
- Data mapper
- Creates shadow object from DB content. Can write changes to this object to the DB. Data mapper separates data access from object representing the data. Fits well into the domain model.
How can objects stored in the database be found using a row data gateway? Name two design approaches. Finder methods. Either as part of a finder class, or static methods of the class returned.
What are the differences between the row data gateway and table data gateway designs? Object representing a full table vs object representing a single row.
Active record? Sounds like a merge of row data gateway and table data gateway. Have one object per row, but keep database access in the table data gateway. Not 100% sure though.
What is the main point of the data mapper pattern and what are its advantages? Separate database access logic from data object. Advantages: Business logic can be implemented in the objects without colliding with the data mapper. Data mapper is independent, can be changed etc.
What are structural mapping patterns? OOP and RDBMs aren't exactly the same. How to match the different structures best?
Find primary keys Simple values: Easy to store in a table column Associations: From foreign keys (1:n mappings) to association tables (n:m)
What is the difference between entities and value objects?
- Entities
- Have a primary key.
- Value objects
- Only attributes matter. Duplicates may exist. Simple examples: Any primitive type in Java, Strings. Often used for data transfer. Value objects can have an owner which determines its identity(e.g. Address belonging to a Person object)
Why should domain model values not be used for the primary key? Are they really unique? They can change What if they disappear?
Name 3 primary key creation strategies
- Keep a counter and increment it
- Search the table for the maximum key and use max + 1
- Generate a random value that is almost certainly unique (e.g. A GUID, use a SHA1 hash, ...)
- Key tables
What is the difference between compound and simple keys?
- Simple keys: Just one value, e.g. an integer
- Compound keys: Multiple values define the key, e.g. Data of Birth + Name + Location of birth
What is the difference between associations in object oriented systems and relational databases?
- OOP: Use pointers. Keep a map or list for 1:n assocs
- RDBMs: Foreign keys. Association tables for n:m assocs.
Associations: 1:1, 1:n, n:1, n:m. What are association classes. How can Many-to-many associations be avoided?
- 1:1: OOP: Pointer. RDBM: foreign key
- 1:n: OOP: collection. RDBM: Foreign key in one table, SQL select to find entities linking to it.
- n:m: Use a association table. Can be avoided by using two many-to-one associations ad OOP level. This is often easier to handle than two collections and allows link attributes.
Association class: A class that contains pointers to two objects and links then together this way. Comparable to an association table in RDBMs. (not sure about this)
How does dependent mapping work? Dependent needs exactly one owner. An owner can own many dependents.
- Row data gateway, active record: Owner contains the mapping code
- Data mapper: Mapping code in the mapper for owner object.
What is an embedded value? An element in the OOP class that doesn't make sense as a separate table or dependent object, for example a date field. The embedded value is split into multiple columns in the table.
What is a serialized large object and what is it used for? What are the advantages and disadvantages? Store unstructured data, for example an image. Advantage: It is a simple way to dump data, and often database systems support it. Disadvantage: Cannot be searched for.
Describe 3 inheritance mapping strategies and name their advantages and disadvantages.
- Single table
- One table for all subclasses, nonexistant objects set to null. Easy, but wastes memory, non-null values cannot be enforced.
- Class table
- One table for each subclass, contains all the data. Avoids memory waste, easy to read one object, but searches have to search all tables.
- Concrete table
- One table containing the base class data, one table per subclass containing subclass specific data plus the primary keys. Easy to read base class, easy to search, memory efficient, but needs a join to load the full object.
Object-relational mapping[Bearbeiten | Quelltext bearbeiten]
Which issues can occur when loading and saving objects to databases? Servant A loads object O from the DB. Servant B loads object O from the DB. Servant A modifies his copy of O. How much data to load? Everything at once? Only as much as needed? Unnecessary data loaded vs load overhead. Primary keys are needed
Name 3 patterns to address the load/save issues and describe them.
- Identity map. Middleware remembers which objects are loaded, when they are loaded the existing instance is returned. Avoids issues when two servants use the same object simultanously. Also reduces memory footprint.
- Lazy load: Don't load the whole object and referenced objects immediately. Instead keep dummy objects or fields around and load them when they are accessed.
- Unit of work: Used to track changes to the objects so the data mapper knows which objects have to be persisted. Related to transactions.
What is a Unit of Work controller? It manages units of work, and especially takes care of registering objects in a unit of work when they were modified. Possible implementation technique: Keep another copy, compare the two copies. Those that are changed need to be written to DB.
Describe the following lazy load implementation strategies: Lazy initialization, Virtual Proxy, Ghost
- Lazy initialization: Object instance is created, but the value fields are set to a value signaling that they have to be loaded from the database(e.g. Set object references to null). When they are accessed, load the value from the DB.
- Virtual Proxy: When an object references another not yet loaded object, don't instanciate the object yet. Instead, set a reference to a proxy object which does not contain any data. When the proxy is accessed, load data from the DB and redirect the reference.
- Ghost: Similar to Lazy init, but one field specifying whether the class is initialized or not, instead of per-member tracking.
What is the N + 1 select problem and which solution strategies exist?
Issue: Object contains a dependent object, e.g. an Address that is part of an object managing informations about a Customer. This dependent obj is stored in a separate DB table. When all objects are loaded, both tables should be accessed efficiently.
Strategies: Load table 1, then select dependent objects one by one. Needs N + 1 selects Load both tables, connect in memory. 2 selects SQL Join. One select, no manual connecting records, but complex object graphics may not be loadable with joins.
Which issues exist with using SQL to find objects? Name the 3 common solutions to this problem and describe them. SQL is powerful, but often complicated. Object-relational mapper is supposed to hide this. Using SQL requires access to database implementation specifics, e.g. table names.
Find by example: An object with the same type of the searched for obj is created, and its fields set to match the search critera. Query object: Query objects allow constructing more powerful searches similar to SQL selects, including relations with >, <, =. They are object oriented wrappers around SQL. Finder method. Can be comfortable, but doesn't allow ad-hoc queries.
What is offline concurrency? Describe the optimistic offline lock and pessimistic offline lock approaches. A client wants to modify data, but this process takes longer than a usual transaction, and often the connection is closed in between. E.g. a user editing a page in a Wiki.
Optimistic lock: All edit requests are granted. When the changes are written, the existing DB content is compared to the one that was there at the beginning. If it is the same, OK. Otherwise error. Alternatively a version can be assigned to avoid comparing the whole content. Pessimistic lock: Once one client edits, all other accesses are denied
Which read/write lock patterns exist?
- Read lock: Only one concurrent read or write
- Write lock: Any number of concurrent reads, one write. Writes don't block reads
- Read-write lock: As long as no write occurs, any number of reads are allowed. If one write lock is requested, further reads and writes are forbidden.
What is a pessimistic offline lock manager? Keeps track of who has obtained a lock on which record, etc. E.g. store locking information.
What are coarse-grained locks? Locks multiple objects at once, e.g. a Person and its Address objects. Used to reduce locking cost if its expected that both objects will be changed together.
What is a data mapper and what is its purpose? Manages persisting and reading of objects. Goal: Separate domain logic from database access code.
What is metadata mapping and what is it used for? Name two common implementation techniques. Object relational mapping code is repetitive to write. Its preferable to define the mappings and generate the ORM code automatically.
- Code generation
- Reflective programming
What are the entities JPA manages, and what requirements do they have? Plain old java objects. Must
- be annotated with @Entity
- have no-arg constructor
- be top level classes
- not be final
What are transient and non-transient fields? Transient fields are not written to the database and are usually used for temporary results. Non-transient fields are persisted.
Outline a JPA Entity's lifecycle!
- New: Newly created, not persisted
- Managed: Persisted
- Detached: In DB, but memory copy changed
- Deleted: Deleted from DB, but still in memory. == new
How can primary keys be generated? Take a primary key from the domain model. Usually a bad idea Increasing integer. Select max(keys) + 1
Name and describe 3 inheritance mapping approaches!
- Single table: All subtypes share one table. Fields that do not apply are set to null. Fast access, but wasted memory, and non-null values are not allowed
- Table per class: One table for every subtype. Allows null values, saves memory, and no joins needed. However, if the exact type is not known when searching for an object all tables have to be searched
- Joined: Base class data is stored in one table, and subtype-specific data is stored in separate tables. Allows partial loading, searching is easy, but a join is required to load all data.
How are associations mapped?
Describe the JPA query language! What are named queries? SQL-Like query language that allows searching for objects in the DB. Queries can be constructed ad-hoc by concatenating strings, or pre-defined in the database with placeholders for fields, and later used by their name.
What is the entity manager and how can it be obtained? Interface to access the persistence manager. Obtained via dependency injection.
Transactions in JPA? Uses the java transaction manager.
Enterprise Java Beans[Bearbeiten | Quelltext bearbeiten]
What types of Beans exist?
- Message beans
- Session beans
- Entity beans
What parts does a EJB bean have?
- Bean implementation
- Business interface(s), remote and/or local.
- Metadata
What are session beans and what interfaces can they implement? What are those interfaces used for? Session beans offer services via Remote Procedure call. Their interfaces can be remote interfaces, callable from outside the Java VM(e.g. From a different computer). There are also local interfaces that are only available in the Bean's JVM. They can be used for communications between the beans.
What kind of session beans exist?
- Stateful
- Stateless
What are the restrictions of business interfaces? What are the communication implications of local and remote interfaces? An interface must be either local or remote. If both are needed on the same interface define a base iface and use inheritance.
Remote interfaces have a high cost for one method call. One big method to return more data at once is often better than many small methods that return a small amount of data compared to the call overhead. On local interfaces the overhead is smaller, so many methods to transfer small amounts of data each are usually better.
How do naming service, server and client interact?
- 1. Server: bind service
- 2. Client: Lookup service
- 3. Client: Call service
What are JNDI service providers? How is JNDI configured? They are the backends that implement the actual naming protocols, like LDAP, CORBA naming and others. An initial configuration for is needed for JNDI and the service providers and can be provided either via a configuration file or
How can beans access resources and other EJBs? Either create or query for them like normal clients(e.g. JNDI). They can also request that the EJB runtime creates an instance and provides it via dependency injection. Beans can request this by annotating the field in the bean implementation class.
What is the Session Context and what can a bean do with it? It contains information about the client and permanent storage. Beans can use it to access the EJB runtime and its services(transactions, ...). The session context also provides information about the current invocation, e.g. which interface was called and the bean that was called.
How does instance pooling work? What is it supposed to achieve? Goal: Optimize performance and memory use of stateless beans
Unused beans are returned to a bean pool. When a new bean is needed, a bean from the bean pool is used, if available, otherwise a new bean is created. This reduces the time needed to instanciate new beans and destroy them afterwards.
The pool size can be set. If it is too big, beans are destroyed.
Lifecycle for stateless and stateful session beans? Lifecycle callbacks? A stateful bean can be passivated if it is not used over a certain(configurable) amount of time, and/or its resources are needed elsewhere. The state is written to permanent storage. If the bean is used again, the state is restored from permanent storage.
Callbacks: PostConstruct, PreDestroy, PrePassivate, PostActivate, Remove callbacks can be implemented by the bean and are called by the runtime on a state change.
Stateless beans are not passivated, instead, no longer used beans are stored in an instance pool, see above.
Name a few technologies to access remote objects that are available in Java Corba, RMI, Web services.
What information does a java object reference contain? Host, Port, Client and server socket factories, transport protocol.
What issues does Java RMI have? At which layers can RMI be extended?
- Java only
- Bad extensibility
- One object per port → limit to less than 65536 objects.
Extension: The whole RMI implementation can be changed. Less invasive: Change the socket factories to make use of a different wire protocol(e.g. RMI over SSL)
What differences does RMI-IIOP have tompared to “native” Corba and to “native” RMI? Corba wire protocol with (almost) the same Code as RMI. Avoids most of the issues that make Corba “complicated”. However, there are a few differences, for example, RMI-Style object casts when querying a service object don't work.
Web services and RMI??? JAX-WS is a java API for XML based web services. Stateless session beans can be used as web services. Different annotation needed: @WebService, @WebMethod. (Stateful web service via vendor-specific JAX-WS RI extension)
Corba:[Bearbeiten | Quelltext bearbeiten]
What is the Corba object adapter and which functions does it offer? A wrapper around a server object. It it automatically generated from the interface definition.
Functions: Interpretation of OBJ references method invocations security obj activation and deactivation obj references ↔ object implementation(? Instances?) mapping
Outline the Corba architecture including the following parts: Client, Dynamic Invocation Interface, Static IDL stubs, ORB, IDL skeleton, dynamic skeleton interface, POA, Interface repository, Implementation repository <draw graph here> Dynamic Invocation interface, dynamic skeleton interface: See below POA: See above Interface repository: Interfaces information stored in the ORB and is available at runtime to perform type checking. Implementation repository: ? Static IDL stubs: ?
What are the Active Object Map and Servant Managers?
What are POA managers and which states do POAs have?
What is the interface repository and what are its use cases? What is the structure of its storage? Give an example. Every active servant needs an entry in the interface repo. The interface information is used, among other things, for typechecking, inheritance checking and compatibility among different ORB implementations.
The root of a repository entry is the interface definition. It can contain other definitions like exception definitions, operation definitions, type definitions, module definitions, ...
What are the Dynamic Invocation Interface and the Dynamic Skeleton Interface? The dynamic invocation interface allows clients to call server methods which were not known at compile time. It is a generic API entrypoint that takes a method name and parameter list and performs the requested remote procedure call.
The Dynamic Skeleton interface is its server-side counterpart. It's a generic method server objects can implement to process requests that were not known at compile time.
Outline the design of the Corba naming service? What can be stored in a naming context? What about the uniqueness of names and objects? Where is the root of the namespace? Root: No global root.
A naming context can contain objects or other naming context. A name in a naming context is unique, but objects can have multiple names.
What is the Corba event service? Corba-speak for message oriented middleware, publish-subscribe style.
Describe push vs pull operation of producer and consumer producer: Push: Producer notifies the message channel about new messages Pull: Channel asks producer about new messages
Consumer: Push: Channel notifies consumer Pull: Consumer queries channel
All 4 combinations are possible: Push-push, push-pull, pull-push, pull-pull
What is the Corba Notification service? Name a few of its features. Extension of the Event service. Adds filters, QoS, standardized lookup of channel factories.
Describe the life of a Corba transaction. 1.Initiated with begin() 2.Passed to server methods 3.Objects add themselves to the transaction to be notified about the outcome 4.End: commit() or rollback()
What are Transactional Clients, Transactional Objects, Transactional Servers, Recoverable Servers, Recoverable objects and the Transaction context? Which role do resources play in a transaction? Transactional clients: Clients that uses transactional objects. Transactional objects: Objects that support transactions(can roll back changes if needed etc) Transactional servers: ? Recoverable objects: ? Recoverable object: ? Transaction context: Contains information about the active transaction. Is passed along in RPC calls as part of the call context by the transaction service, or can be passed explicitly by the programmer.
Resource:blabla
What are shared and unshared transactions? Shared: Client and server use the same transaction. Server can enlist more participants Unshared: Used for asynchronous invocation, whatever that is
What is the purpose of the Corba Persistent State Service? It can be used to load and store objects to permanent storage, e.g. a database to be able to reload them after a server shutdown and restart, or delete them to free resources if they are unused.
What are mirror objects:
Describe the PSS Objects: Storage Object, Storage Home, Datastore, Catalog, Storage object instance, storage object incarnation, storage home instance.
- Datastore
- The database
- Storage object
- Object stored in the database
- Storage home
- Collection of storage objects(abstract storage location)
- Storage object instance
- Active object that corresponds to a storage object in a datastore
- Storage home instance
- system memory instance of a storage home in the datastore.
- Catalog
- Manages connections between storage objects and storage object instances.
Which problem does the Corba Component Model aim to fix? Adds unified deployment No standardized corba server creation method No lifecycle management Services offered by corba implementations not standardized
Which parts does a CCM Component consist of? Equivalent interface: ? Facets: ? Receptables: Connection points for functions provided by other objects. Probably similar to a library import section in executables. Event sources: ? Event sinks: ? Attributes: ?
.NET Remoting and WCF[Bearbeiten | Quelltext bearbeiten]
What distributed systems technologies exist on Windows prior to .NET? Clipboard, OLE, COM, DCOM, Microsoft Transaction server, Microsoft Message Queue Service, COM+
Describe the different class layers inside the .NET Architecture
3: Various frameworks - ASP .NET, web services, web forms, Windows Forms. 2: Data and XML Classes 1: Base framework classes 0: Common Language Runtime
List Services offered by the .NET CLR and describe them:
- Code management
- Memory management
- IL-JIT Compiler
- Security
- Developer services(profiling, debugging)
- Type management
- Process management
- COM interoperability
How does JIT Compilation work? JIT compilation translates MSIL to native code on demand at application runtime. A class is loaded with stub methods. When a method is called the first time, the stub triggers the compilation of .NET bytecode into native code and replaces itself with the compiled code.
How does install time code generation work? The ngen.exe tool can be used to translate all code in a .NET assembly to native code. This is usually a performance improvement, but should be tested to be sure.
What type groups exist in the .NET type system? Name some example types for each group.
- Value types
- System value types(I guess ints), enumerations
- Reference types
- Object references, Arrays, Pointers
What information is stored in a .NET assembly? Version information, required libraries, IL code etc etc...
What is the relation of .NET remoting and DCOM and the Windows Communication Foundation? .NET remoting and DCOM: No direct relational .NET remoting and WCF: WCF is the successor of .NET remoting
What is a .NET Application domain, and what role does .NET remoting play? An application domain is an execution environment for .NET apps. Applications have to use .NET remoting(or WCF) to communicate to other applications outside their domain. Those other domains can be on the same machine, or connected via network.
What happens during a .NET remote procedure call? ????
Describe the .NET message flow and the elements associated with it. Application → Proxy object → formatter → channels → transport sink → wire → transport sink → channels → formatter → Dispatcher → server object
What are .NET remoting channels and sinks? Name some specific sinks? The sink implements the final wire protocol used to transmit the requests, e.g. the HTTP sink for RPC over HTTP. A channel is a chain of sinks. Sinks can implement additional features, like Encryption. Special sinks are the formatter sink and the transport sink.
What are context sink chains? A chain of sinks that applies to all objects in a .NET context – intercepts calls to all objects in the context and can be used to implement add-on features like Transactions, Security etc.
How can .NET remoting be extended? By implementing additional channel sinks(for new services) or transport sinks(for supporting new communication protocols).
How is security implemented in .NET remoting? Implemented as custom-built sinks. Also special transport sinks can be used, e.g. HTTPS or SSL.
Which object types does .NET remoting know? Which are callable? How are interfaces used in remote objects? Objects can either be passed by reference or by value. Only byref objects can be called. Byval obejcts can be used for data transfer.
Byval marshalling: Serializable attribute. Byref: Nothing special needed.
Interfaces are not needed for remoting, but should be used because otherwise the client needs the class implementation source file to use the remote object.
Describe the .NET remoting object activation styles
- Single Call: One instance per call, aka stateless object
- Singleton: One global instance
- Client activated: One object per client session, aka stateful object.
Which invocation types does .NET remoting know?
- Synchronous: Application blocks until result or error returned
- One-way: Call returns immediately, no result or error returned. Fire and forget
- Async with result: See next question
How can asynchronous invocations be done with delegates? Delegates aren't specific to .NET. A delegate object can be created to perform a synchronous call to a remote object(or even a local object). Invoking the delegate performs the call, and returns immediately. The application can later query for result availability or wait for the result and retrieve it from the delegate.
Describe the .NET Lifetime services and core parameters. The .NET lifetime service implements the Lease pattern. As long as Objects have a valid Lease they are not garbage collected. The poll interval(checking for timed out leases) and the initial lease time can be set. Leases are checked by the Lease Manager, and every application domain has its own Lease manager. Furthermore objects can sponsor other objects(including themselves), which allows objects to stay valid even if the Lease expired.
Leases can be renewed explicitly by the client, or automatically every time a method is called.
Name the 3 Programming paradigms in the Windows Communication foundation
- Contract first: Define interfaces, data types, message types etc
- Code first: Reuse old code, make it remoting capable
- WSDL first: Use web service description language
What contracts exist in the WCF? Examples?
- Service contracts: remote interfaces.
- Operations contract: Part of the service contract, defines a method
- Data contract: Transfer classes
- Message contract: For MOM messages
What are WCF service types and which service types does the WCF offer?
- Typed message service: MOM, messages have header info & body
- Untyped message service: MOM, messages are untyped LOBs.
- Typed service: Remote procedure call operation
Describe the contents of a WCF message contract Describes which content goes into a message header, and which content goes into the message body. Header information can be used for message routing.
Which hosting options exist for a WCF service? Also describe the terms EndPoint, Address, Metadata Exchange and Binding. Name a few binding types.
- Binding: Protocol and transport type used to access the service(e.g. HTTPS)
- Address: Human readable location of the service(e.g. Https://foo.bar.com:1234/myservice)
- EndPoint: Where the service can be found and what it is. Binding+Address+Contract
- Metadata exchange: Special endpoint which can be used for querying information about a service.
What is the WCF channel stack and which services does it provide? It provides abstraction of how messages are delivered and what they contain. Additional channels can be used to add additional services like security or reliability guarantees. The bottom of the channel stack is the transport protocol.
WCF service instancing?
- Per call: aka stateless object
- Per session: aka stateful object
- Single: aka singleton
Concurrency modes in WCF? Only one simultanous call to the server Reentrant from one thread – required for callbacks where a callback can call the obejct again. multithreading capable. No checks by WCF, service obj does its own sychronizing
What are the main differences between .NET remote objects and WCF services? Exceptions... Other stuff