Java Reference
In-Depth Information
As for physical recording, the last stable state is restored and all the sub-
sequent state transitions re-applied, i.e. all the operations that cause the
state transitions are redone. This is achieved using the reflection mecha-
nism. Reflection exploits the information stored in the log file to generate
the same external events (method invocations) that caused state transitions
in the objects of the recoverable domain.
It is important to note that the tracking process needs to be disabled
during the recovery phase. In fact, when logical tracking is performed, the
redo of an operation causes the re-execution of the entire method and,
therefore, the recording of its invocation. Actually, transactional systems
do record undo and redo operations in the log file but, for the sake of
simplicity, we prefer to disregard this functionality.
Decision point
How does the tracker record complex operations (logical recording)?
Every operation of a recoverable class can be tracked using the logical
recording mechanism, but for every specific recoverable application the
program developer should choose whether to track complex or simple oper-
ations. In fact, tracking a complex operation and its component simple
operations makes the undo and redo operations non-idempotent. During the
normal evolution of an application, the execution of a complex execution
causes the execution of all the nested simple or complex operations. Thus,
tracking the top-level complex operation is enough to re-execute it and its
component operations during the recovery phase. Conversely, tracking all
complex and simple operations causes multiple re-executions of the same
operation, making the application's state inconsistent.
18.5.3
Implementation
The implementation of the second prototype requires the extensions of class
Entry and class Tracker in order to support operations' logical recording. In
particular, array “parameters” and “arguments” are added to the definition
of class Entry in order to store all the information that defines a method invo-
cation. Method invoke() uses reflection to re-execute the saved operation.
package recap;
import java.io.*;
import java.lang.reflect.*;
public class Entry implements Serializable {
private Trackable target # null ;
// a copy of a recoverable object
private String targetRef;
// the label of a recoverable object
private String methodName;
 
Search WWH ::




Custom Search