SuperiorInfopublic class SuperiorInfo extends Object The SuperiorInfo interface provides operations that record the local
transaction ID, global transaction ID for the superior (client) and the
superior Coordinator.
As an instance of this class may be accessed from multiple threads within
a process, serialisation for thread-safety is necessary in the
implementation. The information recorded in an instance of this class
needs to be reconstructible in the case of a system failure. |
Fields Summary |
---|
Long | localTIDThe local identifier for the transaction. | GlobalTID | globalTIDThe global identifier for the transaction. | Coordinator | superiorThe reference of the superior Coordinator. | RecoveryCoordinator | recoveryThe reference of the RecoveryCoordinator returned on the
register_resource call to the superior Coordinator,
if any. Note that this member may be directly read,
but must be set using the setRecovery method in this class. | SubtransactionAwareResource | resourceThe reference of the Resource registered on the
register_resource call to the superior Coordinator, if any.
Note that this member may be directly
read, but must be set using the setResource method in this class. | private CoordinatorLog | logRecord | private Object | logSection | private int | resyncRetries | private static final String | LOG_SECTION_NAME |
Constructors Summary |
---|
SuperiorInfo()Default SuperiorInfo constructor.
| SuperiorInfo(Long localTID, GlobalTID globalTID, Coordinator superior, CoordinatorLog log)Defines the local transaction ID, global ID and superior Coordinator
reference.
The CoordinatorLog is used as the basis for recovering the
SuperiorInfo at restart. The SuperiorInfo section in the CoordinatorLog
is created, with the global identifier added to the section.
this.localTID = localTID;
this.globalTID = globalTID;
this.superior = superior;
recovery = null;
resource = null;
logRecord = log;
resyncRetries = 0;
// Set up CoordinatorLog section for this class
if (log != null) {
// Create a section in the CoordinatorLog for SuperiorInfo
logSection = log.createSection(LOG_SECTION_NAME);
// Add the Global Id to the SuperiorInfo section of the log
log.addData(logSection,globalTID.toBytes());
}
|
Methods Summary |
---|
void | delegated_reconstruct(CoordinatorLog log, CoordinatorImpl coord, java.lang.String logPath)
superior = null;
// Recover our state from the CoordinatorLog object.
// Get the section id in the CoordinatorLog for SuperiorInfo
logSection = log.createSection(LOG_SECTION_NAME);
byte[][] logData = log.getData(logSection);
// Construct the global identifier.
globalTID = new GlobalTID(logData[0]);
// Get the local transaction identifier from the CoordinatorLog
// attribute rather than from the log record itself.
localTID = log.localTID;
logRecord = log;
resyncRetries = 0;
// Add the Coordinator to the RecoveryManager map. This is
// to allow the recovery of the CoordinatorResource reference,
// which results in a call to getCoordinator.
DelegatedRecoveryManager.addCoordinator(globalTID, localTID, coord, 0, logPath);
// Get all objects that were logged. If this SuperiorInfo represents
// a root TopCoordinator object, then there will be no objects logged.
java.lang.Object[] logObjects = log.getObjects(logSection);
try {
if (logObjects.length > 1) {
if (((org.omg.CORBA.Object) logObjects[0]).
_is_a(RecoveryCoordinatorHelper.id())) {
// TN - used to be com.sun.CORBA.iiop.CORBAObjectImpl
java.lang.Object rcimpl = logObjects[0];
String[] ids = StubAdapter.getTypeIds(rcimpl);
/*
for (int i = 0; i < ids.length; i++)
if( trc != null )
trc.exit(998).data(i).data(ids[i]).write();
*/
// TN - used to be com.sun.CORBA.iiop.CORBAObjectImpl
java.lang.Object crimpl = logObjects[1];
ids = StubAdapter.getTypeIds(crimpl);
/*
for( int i = 0; i < ids.length; i++ )
if( trc != null )
trc.exit(998).data(i).data(ids[i]).write();
*/
recovery = RecoveryCoordinatorHelper.
narrow((org.omg.CORBA.Object) logObjects[0]);
resource = SubtransactionAwareResourceHelper.
narrow((org.omg.CORBA.Object) logObjects[1]);
} else {
recovery = RecoveryCoordinatorHelper.
narrow((org.omg.CORBA.Object) logObjects[1]);
resource = SubtransactionAwareResourceHelper.
narrow((org.omg.CORBA.Object) logObjects[0]);
}
} else {
recovery = null;
resource = null;
}
} catch (Throwable exc) {}
| public void | doFinalize()Cleans up the objects state.
// Destroy the global transaction identifier.
//$ if( globalTID != null ) globalTID.finalize();
// Release superior Coordinator references.
if (superior != null &&
!(superior instanceof org.omg.CORBA.LocalObject)) {
superior._release();
}
//$#ifndef OTS_DEFERRED_REGISTRATION
//$For deferred registration, the CurrentTransaction
//$will release the proxy, so there is no need to do it here.
//$For non-deferred registration, the RecoveryCoordinator
//$must be destroyed by the subordinate as no-one else will.
if (recovery != null &&
!(recovery instanceof org.omg.CORBA.LocalObject)) {
recovery._release();
}
//$#endif /* OTS_DEFERRED_REGISTRATION */
localTID = null;
globalTID = null;
superior = null;
recovery = null;
resource = null;
| void | reconstruct(CoordinatorLog log, CoordinatorImpl coord)Directs the SuperiorInfo to recover its state after a failure, based on
the given CoordinatorLog object.
The SuperiorInfo then adds the given Coordinator to the
RecoveryManager mappings. If the SuperiorInfo has already been defined
or reconstructed, the operation does nothing.
If the state cannot be reconstructed, the
Coordinator is not added.
The global identifier, local ID, RecoveryCoordinator
and CoordinatorResource object references are restored.
superior = null;
// Recover our state from the CoordinatorLog object.
// Get the section id in the CoordinatorLog for SuperiorInfo
logSection = log.createSection(LOG_SECTION_NAME);
byte[][] logData = log.getData(logSection);
// Construct the global identifier.
globalTID = new GlobalTID(logData[0]);
// Get the local transaction identifier from the CoordinatorLog
// attribute rather than from the log record itself.
localTID = log.localTID;
logRecord = log;
resyncRetries = 0;
// Add the Coordinator to the RecoveryManager map. This is
// to allow the recovery of the CoordinatorResource reference,
// which results in a call to getCoordinator.
RecoveryManager.addCoordinator(globalTID, localTID, coord, 0);
// Get all objects that were logged. If this SuperiorInfo represents
// a root TopCoordinator object, then there will be no objects logged.
java.lang.Object[] logObjects = log.getObjects(logSection);
try {
if (logObjects.length > 1) {
if (((org.omg.CORBA.Object) logObjects[0]).
_is_a(RecoveryCoordinatorHelper.id())) {
// TN - used to be com.sun.CORBA.iiop.CORBAObjectImpl
java.lang.Object rcimpl = logObjects[0];
String[] ids = StubAdapter.getTypeIds(rcimpl);
/*
for (int i = 0; i < ids.length; i++)
if( trc != null )
trc.exit(998).data(i).data(ids[i]).write();
*/
// TN - used to be com.sun.CORBA.iiop.CORBAObjectImpl
java.lang.Object crimpl = logObjects[1];
ids = StubAdapter.getTypeIds(crimpl);
/*
for( int i = 0; i < ids.length; i++ )
if( trc != null )
trc.exit(998).data(i).data(ids[i]).write();
*/
recovery = RecoveryCoordinatorHelper.
narrow((org.omg.CORBA.Object) logObjects[0]);
resource = SubtransactionAwareResourceHelper.
narrow((org.omg.CORBA.Object) logObjects[1]);
} else {
recovery = RecoveryCoordinatorHelper.
narrow((org.omg.CORBA.Object) logObjects[1]);
resource = SubtransactionAwareResourceHelper.
narrow((org.omg.CORBA.Object) logObjects[0]);
}
} else {
recovery = null;
resource = null;
}
} catch (Throwable exc) {}
| int | resyncRetries()Returns the number of retries so far, and increments the count.
int result = resyncRetries++;
return result;
| void | setRecovery(RecoveryCoordinator rec)Records the RecoveryCoordinator for the transaction.
if (recovery == null) {
recovery = rec;
// Add the RecoveryCoordinator to the CoordinatorLog object
if (logRecord != null) {
logRecord.addObject(logSection, rec);
}
}
| void | setResource(SubtransactionAwareResource res)Records the CoordinatorResource for the transaction.
if (resource == null) {
resource = res;
// Add the CoordinatorResource to the CoordinatorLog object
if (logRecord != null) {
logRecord.addObject(logSection, res);
}
}
|
|