use of com.arjuna.ats.arjuna.StateManager in project narayana by jbosstm.
the class TxLogWritePersistenceRecord method topLevelPrepare.
/**
* topLevelPrepare attempts to save the object.
* It will either do this in the action intention list or directly
* in the object store by using the 'deactivate' function of the object
* depending upon the size of the state.
* To ensure that objects are correctly hidden while they are in an
* uncommitted state if we use the abbreviated protocol then we write an
* EMPTY object state as the shadow state - THIS MUST NOT BE COMMITTED.
* Instead we write_committed the one saved in the intention list.
* If the store cannot cope with being given an empty state we revert to
* the old protocol.
*/
public int topLevelPrepare() {
int result = TwoPhaseOutcome.PREPARE_NOTOK;
StateManager sm = super.objectAddr;
LogWriteStateManager lwsm = null;
boolean writeToLog = true;
try {
lwsm = (LogWriteStateManager) sm;
writeToLog = lwsm.writeOptimisation();
} catch (ClassCastException ex) {
writeToLog = false;
}
if ((sm != null) && (targetParticipantStore != null)) {
topLevelState = new OutputObjectState(sm.get_uid(), sm.type());
if (writeToLog || (!targetParticipantStore.fullCommitNeeded() && (sm.save_state(topLevelState, ObjectType.ANDPERSISTENT)) && (topLevelState.size() <= PersistenceRecord.MAX_OBJECT_SIZE))) {
if (PersistenceRecord.classicPrepare) {
OutputObjectState dummy = new OutputObjectState(Uid.nullUid(), null);
try {
targetParticipantStore.write_uncommitted(sm.get_uid(), sm.type(), dummy);
result = TwoPhaseOutcome.PREPARE_OK;
} catch (ObjectStoreException e) {
tsLogger.i18NLogger.warn_PersistenceRecord_21(e);
}
dummy = null;
} else {
result = TwoPhaseOutcome.PREPARE_OK;
}
} else {
if (sm.deactivate(targetParticipantStore.getStoreName(), false)) {
shadowMade = true;
result = TwoPhaseOutcome.PREPARE_OK;
} else {
tsLogger.i18NLogger.warn_PersistenceRecord_7();
}
}
} else {
tsLogger.i18NLogger.warn_PersistenceRecord_8();
}
return result;
}
use of com.arjuna.ats.arjuna.StateManager in project narayana by jbosstm.
the class PersistenceRecord method topLevelPrepare.
/**
* topLevelPrepare attempts to save the object. It will either do this in
* the action intention list or directly in the object store by using the
* 'deactivate' function of the object depending upon the size of the state.
* To ensure that objects are correctly hidden while they are in an
* uncommitted state if we use the abbreviated protocol then we write an
* EMPTY object state as the shadow state - THIS MUST NOT BE COMMITTED.
* Instead we write_committed the one saved in the intention list. If the
* store cannot cope with being given an empty state we revert to the old
* protocol.
*/
public int topLevelPrepare() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("PersistenceRecord::topLevelPrepare() for " + order());
}
int result = TwoPhaseOutcome.PREPARE_NOTOK;
StateManager sm = super.objectAddr;
if ((sm != null) && (targetParticipantStore != null)) {
/*
* Get ready to create our state to be saved. At this stage we're not
* sure if the state will go into its own log or be written into the
* transaction log for improved performance.
*/
topLevelState = new OutputObjectState(sm.get_uid(), sm.type());
if (writeOptimisation && (!targetParticipantStore.fullCommitNeeded() && (sm.save_state(topLevelState, ObjectType.ANDPERSISTENT)) && (topLevelState.size() <= PersistenceRecord.MAX_OBJECT_SIZE))) {
if (PersistenceRecord.classicPrepare) {
OutputObjectState dummy = new OutputObjectState(Uid.nullUid(), null);
try {
if (targetParticipantStore.write_uncommitted(sm.get_uid(), sm.type(), dummy))
result = TwoPhaseOutcome.PREPARE_OK;
else {
result = TwoPhaseOutcome.PREPARE_NOTOK;
}
} catch (ObjectStoreException e) {
tsLogger.i18NLogger.warn_PersistenceRecord_21(e);
}
dummy = null;
} else {
/*
* Don't write anything as our state will go into the log.
*/
result = TwoPhaseOutcome.PREPARE_OK;
}
} else {
if (sm.deactivate(targetParticipantStore.getStoreName(), false)) {
shadowMade = true;
result = TwoPhaseOutcome.PREPARE_OK;
} else {
topLevelState = null;
tsLogger.i18NLogger.warn_PersistenceRecord_7();
}
}
} else {
tsLogger.i18NLogger.warn_PersistenceRecord_8();
}
return result;
}
use of com.arjuna.ats.arjuna.StateManager in project narayana by jbosstm.
the class ObjStoreBrowser method setType.
/**
* Tell the browser which beans to use for particular Object Store Action type
* @param osTypeClassName
* @param beanTypeClassName
* @return whether the type was set OK
*/
public boolean setType(String osTypeClassName, String beanTypeClassName) {
try {
Class cls = Class.forName(osTypeClassName);
StateManager sm = (StateManager) cls.getConstructor().newInstance();
String typeName = canonicalType(sm.type());
if (typeName == null || typeName.length() == 0)
return false;
osbTypeMap.put(typeName, new OSBTypeHandler(true, osTypeClassName, beanTypeClassName, typeName, null));
typeName = typeName.replaceAll("/", File.separator);
osbTypeMap.put(typeName, new OSBTypeHandler(true, osTypeClassName, beanTypeClassName, typeName, null));
return true;
} catch (Exception e) {
if (tsLogger.logger.isDebugEnabled())
tsLogger.logger.debug("Invalid class type in system property ObjStoreBrowserHandlers: " + osTypeClassName);
return false;
}
}
Aggregations