[jboss-svn-commits] JBL Code SVN: r30036 - in labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats: arjuna/coordinator and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 5 16:36:20 EST 2009
Author: mark.little at jboss.com
Date: 2009-11-05 16:36:20 -0500 (Thu, 05 Nov 2009)
New Revision: 30036
Added:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverActivationRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java
Removed:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverActivationRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ActivationRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordType.java
Log:
https://jira.jboss.org/jira/browse/JBTM-639
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ActivationRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ActivationRecord.java 2009-11-05 21:28:50 UTC (rev 30035)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/ActivationRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -41,246 +41,260 @@
import com.arjuna.common.util.logging.*;
-
public class ActivationRecord extends AbstractRecord
{
/*
- * This constructor is used to create a new instance of an
- * ActivationRecord.
+ * This constructor is used to create a new instance of an ActivationRecord.
*/
-
- public ActivationRecord (int st, StateManager sm, BasicAction action)
+
+ public ActivationRecord(int st, StateManager sm, BasicAction action)
{
- super(sm.get_uid(), sm.type(), ObjectType.ANDPERSISTENT);
-
- objectAddr = sm;
- actionHandle = action;
- state = st;
+ super(sm.get_uid(), sm.type(), ObjectType.ANDPERSISTENT);
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "ActivationRecord::ActivationRecord("+state+", "+sm.get_uid()+")");
- }
+ objectAddr = sm;
+ actionHandle = action;
+ state = st;
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::ActivationRecord(" + state + ", "
+ + sm.get_uid() + ")");
+ }
}
-
+
public int typeIs ()
{
- return RecordType.ACTIVATION;
+ return RecordType.ACTIVATION;
}
-
+
public Object value ()
{
- return (Object) new Integer(state);
+ return (Object) new Integer(state);
}
-
+
/**
- * @message com.arjuna.ats.arjuna.ActivationRecord_1 [com.arjuna.ats.arjuna.ActivationRecord_1] ActivationRecord::set_value() called illegally
+ * @message com.arjuna.ats.arjuna.ActivationRecord_1
+ * [com.arjuna.ats.arjuna.ActivationRecord_1]
+ * ActivationRecord::set_value() called illegally
*/
public void setValue (Object v)
{
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.ActivationRecord_1");
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N
+ .warn("com.arjuna.ats.arjuna.ActivationRecord_1");
}
-
+
/**
* nestedAbort causes the reset_state function of the object to be invoked
* passing it the saved ObjectStatus.
*/
-
+
public int nestedAbort ()
{
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "ActivationRecord::nestedAbort() for "+order());
- }
-
- int outcome = TwoPhaseOutcome.FINISH_ERROR;
-
- if ((objectAddr != null) && (actionHandle != null))
- outcome = (objectAddr.forgetAction(actionHandle, false, RecordType.ACTIVATION) ? TwoPhaseOutcome.FINISH_OK : TwoPhaseOutcome.FINISH_ERROR);
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::nestedAbort() for " + order());
+ }
- return outcome;
+ int outcome = TwoPhaseOutcome.FINISH_ERROR;
+
+ if ((objectAddr != null) && (actionHandle != null))
+ outcome = (objectAddr.forgetAction(actionHandle, false,
+ RecordType.ACTIVATION) ? TwoPhaseOutcome.FINISH_OK
+ : TwoPhaseOutcome.FINISH_ERROR);
+
+ return outcome;
}
/**
- * nestedCommit does nothing since the passing of the state up to
- * the parent action is handled by the record list merging system.
- * In fact since nested_prepare returns PREPARE_READONLY this function should
- * never actually be called.
+ * nestedCommit does nothing since the passing of the state up to the parent
+ * action is handled by the record list merging system. In fact since
+ * nested_prepare returns PREPARE_READONLY this function should never
+ * actually be called.
*/
-
-public int nestedCommit ()
+
+ public int nestedCommit ()
{
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "ActivationRecord::nestedCommit() for "+order());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::nestedCommit() for " + order());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
}
-public int nestedPrepare ()
+ public int nestedPrepare ()
{
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "ActivationRecord::nestedPrepare() for "+order());
- }
-
- return TwoPhaseOutcome.PREPARE_READONLY;
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::nestedPrepare() for " + order());
+ }
+
+ return TwoPhaseOutcome.PREPARE_READONLY;
}
-
+
/**
- * topLevelAbort for Activation records is exactly like a nested
- * abort.
+ * topLevelAbort for Activation records is exactly like a nested abort.
*/
-
+
public int topLevelAbort ()
{
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "ActivationRecord::topLevelAbort() for "+order());
- }
-
- return nestedAbort(); /* i.e., same as nested case */
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::topLevelAbort() for " + order());
+ }
+
+ return nestedAbort(); /* i.e., same as nested case */
}
-
+
/*
- * topLevelCommit has little to do for ActivationRecords other
- * than to ensure the object is forgotten by the object.
+ * topLevelCommit has little to do for ActivationRecords other than to
+ * ensure the object is forgotten by the object.
*/
-
+
public int topLevelCommit ()
{
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "ActivationRecord::topLevelCommit() for "+order());
- }
-
- if ((objectAddr != null) && (actionHandle != null))
- {
- return (objectAddr.forgetAction(actionHandle, true, RecordType.ACTIVATION) ? TwoPhaseOutcome.FINISH_OK : TwoPhaseOutcome.FINISH_ERROR);
- }
-
- return TwoPhaseOutcome.FINISH_ERROR;
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::topLevelCommit() for " + order());
+ }
+
+ if ((objectAddr != null) && (actionHandle != null))
+ {
+ return (objectAddr.forgetAction(actionHandle, true,
+ RecordType.ACTIVATION) ? TwoPhaseOutcome.FINISH_OK
+ : TwoPhaseOutcome.FINISH_ERROR);
+ }
+
+ return TwoPhaseOutcome.FINISH_ERROR;
}
-
+
public int topLevelPrepare ()
{
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "ActivationRecord::topLevelPrepare() for "+order());
- }
-
- if (objectAddr == null)
- return TwoPhaseOutcome.PREPARE_NOTOK;
- else
- return TwoPhaseOutcome.PREPARE_OK;
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::topLevelPrepare() for " + order());
+ }
+
+ if (objectAddr == null)
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ else
+ return TwoPhaseOutcome.PREPARE_OK;
}
-
+
/**
- * Saving of ActivationRecords is only undertaken during the Prepare
- * phase of the top level 2PC.
- *
- * @message com.arjuna.ats.arjuna.ActivationRecord_2 [com.arjuna.ats.arjuna.ActivationRecord_2] Invocation of ActivationRecord::restore_state for {0} inappropriate - ignored for {1}
+ * Saving of ActivationRecords is only undertaken during the Prepare phase
+ * of the top level 2PC.
+ *
+ * @message com.arjuna.ats.arjuna.ActivationRecord_2
+ * [com.arjuna.ats.arjuna.ActivationRecord_2] Invocation of
+ * ActivationRecord::restore_state for {0} inappropriate - ignored
+ * for {1}
*/
-
+
public boolean restore_state (InputObjectState os, int v)
{
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.ActivationRecord_2", new Object[]{type(), order()} );
- }
-
- return false;
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn(
+ "com.arjuna.ats.arjuna.ActivationRecord_2", new Object[]
+ { type(), order() });
+ }
+
+ return false;
}
-
+
public boolean save_state (OutputObjectState os, ObjectType v)
{
- return true;
+ return true;
}
-
+
public void print (PrintWriter strm)
{
- super.print(strm);
- strm.println("ActivationRecord with state:\n"+state);
+ super.print(strm);
+ strm.println("ActivationRecord with state:\n" + state);
}
-
+
public String type ()
{
- return "/StateManager/AbstractRecord/ActivationRecord";
+ return "/StateManager/AbstractRecord/ActivationRecord";
}
-
+
public void merge (AbstractRecord a)
{
}
-
+
public void alter (AbstractRecord a)
{
}
-
+
/*
- * should_merge and should_replace are invoked by the record list manager
- * to determine if two records should be merged togethor or if the
- * 'newer' should replace the older.
- * shouldAdd determines if the new record should be added in addition
- * to the existing record and is currently only invoked if both of
- * should_merge and should_replace return FALSE
- * Default implementations here always return FALSE - ie new records
- * do not override old
+ * should_merge and should_replace are invoked by the record list manager to
+ * determine if two records should be merged togethor or if the 'newer'
+ * should replace the older. shouldAdd determines if the new record should
+ * be added in addition to the existing record and is currently only invoked
+ * if both of should_merge and should_replace return FALSE Default
+ * implementations here always return FALSE - ie new records do not override
+ * old
*/
-
+
public boolean shouldAdd (AbstractRecord a)
{
- return false;
+ return false;
}
-
+
public boolean shouldAlter (AbstractRecord a)
{
- return false;
+ return false;
}
-
+
public boolean shouldMerge (AbstractRecord a)
{
- return false;
+ return false;
}
-
+
public boolean shouldReplace (AbstractRecord a)
{
- return false;
+ return false;
}
-
- public ActivationRecord ()
+
+ public ActivationRecord()
{
- super();
-
- objectAddr = null;
- actionHandle = null;
- state = ObjectStatus.PASSIVE;
+ super();
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PROTECTED,
- FacilityCode.FAC_ABSTRACT_REC, "ActivationRecord::ActivationRecord()");
- }
+ objectAddr = null;
+ actionHandle = null;
+ state = ObjectStatus.PASSIVE;
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PROTECTED,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "ActivationRecord::ActivationRecord()");
+ }
}
-
+
private StateManager objectAddr;
- private BasicAction actionHandle;
- private int state;
-
-}
+ private BasicAction actionHandle;
+ private int state;
+}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverActivationRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverActivationRecord.java 2009-11-05 21:28:50 UTC (rev 30035)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverActivationRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: CadaverActivationRecord.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.arjuna;
-
-import com.arjuna.ats.arjuna.logging.tsLogger;
-import com.arjuna.ats.arjuna.logging.FacilityCode;
-
-import com.arjuna.ats.arjuna.coordinator.*;
-
-import com.arjuna.common.util.logging.*;
-
-/*
- * This constructor is used to create a new instance of an
- * CadaverActivationRecord.
- */
-
-class CadaverActivationRecord extends ActivationRecord
-{
-
- public CadaverActivationRecord (StateManager sm)
- {
- super(ObjectStatus.PASSIVE, sm, null);
-
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::CadaverActivationRecord(" +sm.get_uid()+")");
- }
- }
-
- public boolean propagateOnAbort ()
- {
- return true;
- }
-
- /*
- * Supress all atomic action ops for deleted object
- */
-
- public int nestedAbort ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::nestedAbort() for "+get_uid());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- public int nestedCommit ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::nestedCommit() for "+get_uid());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- public int nestedPrepare ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::nestedPrepare() for "+get_uid());
- }
-
- return TwoPhaseOutcome.PREPARE_READONLY;
- }
-
- public int topLevelAbort ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::topLevelAbort() for "+get_uid());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- public int topLevelCommit ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::topLevelCommit() for "+get_uid());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- public int topLevelPrepare ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::topLevelPrepare() for "+get_uid());
- }
-
- return TwoPhaseOutcome.PREPARE_READONLY;
- }
-
- public String type ()
- {
- return "/StateManager/AbstractRecord/CadaverActivationRecord";
- }
-
- /*
- * shouldMerge and should_replace are invoked by the record list manager
- * to determine if two records should be merged togethor or if the
- * 'newer' should replace the older.
- * shouldAdd determines if the new record should be added in addition
- * to the existing record and is currently only invoked if both of
- * shouldMerge and shouldReplace return false
- * Default implementations here always return false - ie new records
- * do not override old
- */
-
- public boolean shouldReplace (AbstractRecord ar)
- {
- return (((order().equals(ar.order())) &&
- ar.typeIs() == RecordType.ACTIVATION ) ? true : false);
- }
-
- protected CadaverActivationRecord ()
- {
- super();
-
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PROTECTED,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverActivationRecord::CadaverActivationRecord ()");
- }
- }
-
-}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverRecord.java 2009-11-05 21:28:50 UTC (rev 30035)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -1,440 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000, 2001,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: CadaverRecord.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.arjuna;
-
-import com.arjuna.ats.arjuna.logging.tsLogger;
-import com.arjuna.ats.arjuna.logging.FacilityCode;
-
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.state.*;
-import java.io.PrintWriter;
-
-import com.arjuna.common.util.logging.*;
-
-import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-
-/**
- * Cadaver records are created whenever a persistent object is deleted while
- * still in the scope of an atomic action. This ensures that if the
- * action commits the state of the persistent objects gets properly
- * reflected back in the object store. For objects that are only
- * recoverable such work is unnecessary. Cadaver records replace
- * PersistenceRecords in the record list of an atomic action so they must
- * be merged with such records to enable both commits and aborts to occur.
- *
- * @author Mark Little (mark at arjuna.com)
- * @version $Id: CadaverRecord.java 2342 2006-03-30 13:06:17Z $
- * @since JTS 1.0.
- */
-
-public class CadaverRecord extends PersistenceRecord
-{
-
- /**
- * Create a new instance, passing in the object that is being managed.
- *
- * @param os the state of the object that is being
- * removed.
- * @param objStore the object store instance used to manipulate the
- * persistent state.
- * @param sm the object being removed.
- */
-
- public CadaverRecord (OutputObjectState os, ObjectStore objStore,
- StateManager sm)
- {
- super(os, objStore, sm);
-
- newStateIsValid = ((os != null) ? true : false);
- oldState = null;
- oType = RecordType.NONE_RECORD;
- store = objStore; // implicit ref count in Java
-
- if (store != null)
- {
- /*
- * If the object goes out of scope its object store may
- * be inaccessable - increase reference count to compensate
- */
-
- /*
- * Don't need this in Java.
- */
-
- // ObjectStore.reference(store);
- }
-
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "CadaverRecord::CadaverRecord("+os+", "+sm.get_uid()+")");
- }
- }
-
- /**
- * Override default AbstractRecord method. CadaverRecords are propagated
- * regardless of the termination condition.
- *
- * @return <code>true</code>
- */
-
- public boolean propagateOnAbort ()
- {
- return true;
- }
-
- /**
- * The type of the record.
- *
- * @return RecordType.PERSISTENT
- * @see com.arjuna.ats.arjuna.coordinator.RecordType
- */
-
- public int typeIs ()
- {
- return RecordType.PERSISTENCE;
- }
-
- /**
- * The nested transaction has aborted. The record will invalidate any
- * new state.
- *
- * @message com.arjuna.ats.arjuna.CadaverRecord_1 [com.arjuna.ats.arjuna.CadaverRecord_1] Attempted abort operation on deleted object id {0} of type {1} ignored
- */
-
- public int nestedAbort ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::nestedAbort() for "+order());
- }
-
- if (oldState != null)
- newStateIsValid = false;
-
- if (oType == RecordType.RECOVERY)
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.CadaverRecord_1",
- new Object[]{ order(), getTypeOfObject() } );
- }
- }
-
- /*
- * No need to forget the action since this object is
- * being deleted so it is unlikely to have modified called
- * on it!
- */
-
- // super.forgetAction(false);
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- /**
- * The nested transaction is preparing. If there is any new state for
- * the object being removed, and that state is valid, then this record
- * will call nestedPrepare on the object being removed.
- *
- * If we have no new state then we cannot commit and must force an
- * abort. Do this by failing the prepare phase.
- */
-
- public int nestedPrepare ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::nestedPrepare() for "+order());
- }
-
- if (newStateIsValid)
- return super.nestedPrepare();
- else
- return TwoPhaseOutcome.PREPARE_NOTOK;
- }
-
- /**
- * The nested transaction has aborted. Invalidate any new state.
- */
-
- public int topLevelAbort ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::topLevelAbort() for "+order());
- }
-
- newStateIsValid = false;
-
- if (oType == RecordType.RECOVERY)
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.CadaverRecord_1",
- new Object[]{ order(), getTypeOfObject() } );
- }
- }
-
- // super.forgetAction(false);
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- /**
- * At topLevelCommit we commit the uncommitted version already saved
- * into object store.
- * Cannot use inherited version since that assumes object is alive
- * instead talk directly to the object store itself.
- */
-
- public int topLevelCommit ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::topLevelCommit() for "+order());
- }
-
- boolean res = true;
- OutputObjectState oState = super.state;
-
- if ((oState != null) && (oType == RecordType.PERSISTENCE))
- {
- if (store == null)
- return TwoPhaseOutcome.FINISH_ERROR;
-
- try
- {
- res = store.commit_state(oState.stateUid(), oState.type());
- }
- catch (ObjectStoreException e)
- {
- res = false;
- }
- }
-
- // super.forgetAction(false);
-
- return ((res) ? TwoPhaseOutcome.FINISH_OK : TwoPhaseOutcome.FINISH_ERROR);
- }
-
- /**
- * At topLevelPrepare write uncommitted version into object store.
- * Cannot use inherited version since that assumes object is alive
- * instead talk directly to the object store itself.
- */
-
- public int topLevelPrepare ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::topLevelPrepare() for "+order());
- }
-
- int tlpOk = TwoPhaseOutcome.PREPARE_NOTOK;
- OutputObjectState oState = (newStateIsValid ? super.state : oldState);
-
- if (oState != null)
- {
- if (oType == RecordType.PERSISTENCE)
- {
- if (store == null)
- return TwoPhaseOutcome.PREPARE_NOTOK;
-
- try
- {
- if (store.write_uncommitted(oState.stateUid(), oState.type(), oState))
- {
- if (shadowForced())
- tlpOk = TwoPhaseOutcome.PREPARE_OK;
- }
- }
- catch (ObjectStoreException e)
- {
- }
- }
- else
- tlpOk = TwoPhaseOutcome.PREPARE_OK;
- }
-
- return tlpOk;
- }
-
- /**
- * Override AbstractRecord.print to write specific information to
- * the specified stream.
- *
- * @param strm the stream to use.
- */
-
- public void print (PrintWriter strm)
- {
- strm.println("Cadaver for:");
- super.print(strm);
- }
-
- /**
- * The type of the class - may be used to save information in an
- * hierarchical manner in the object store.
- */
-
- public String type()
- {
- return "/StateManager/AbstractRecord/RecoveryRecord/PersistenceRecord/CadaverRecord";
- }
-
- /**
- * Override the AbstractRecord.doSave.
- *
- * @return <code>true</code> if the object being removed is a persistent
- * object (RecordType.PERSISTENT). <code>false</code> otherwise.
- * @see com.arjuna.ats.arjuna.coordinator.RecordType
- */
-
- public boolean doSave ()
- {
- if (oType == RecordType.PERSISTENCE)
- return true;
- else
- return false;
- }
-
- /**
- * merge takes the information from the incoming PersistenceRecord and
- * uses it to initialise the oldState information. This is required
- * for processing of action aborts since CadaverRecords maintain the
- * final state of an object normally - which is required if the action
- * commits.
- *
- * @param mergewith The record to merge with.
- */
-
- public void merge (AbstractRecord mergewith)
- {
- /*
- * Following assumes that value returns a pointer to the
- * old state maintained in the PersistenceRecord (as an ObjectState).
- * Here we create a copy of that state allowing the original
- * to be deleted
- */
-
- oType = mergewith.typeIs();
-
- if (oldState != null)
- {
- if (newStateIsValid)
- {
- oldState = null;
- }
- else
- {
- setValue(oldState);
- newStateIsValid = true;
- }
- }
-
- oldState = new OutputObjectState((OutputObjectState)(mergewith.value()));
- }
-
- /**
- * Overrides AbstractRecord.shouldMerge
- *
- * @param ar the record to potentially merge with.
- *
- * @return <code>true</code> if this instance and the parameter have the
- * same id (order()) and the parameter is either persistent or recoverable.
- * <code>false</code> otherwise.
- * @see com.arjuna.ats.arjuna.coordinator.RecordType
- */
-
- public boolean shouldMerge (AbstractRecord ar)
- {
- return (((order().equals(ar.order())) &&
- ((ar.typeIs() == RecordType.PERSISTENCE) ||
- (ar.typeIs() == RecordType.RECOVERY)))
- ? true : false);
- }
-
- /**
- * Overrides AbstractRecord.shouldReplace
- *
- * @param ar the record to potentially replace this
- * instance.
- *
- * @return <code>true</code> if this instance and the parameter have the
- * same id (order()) and the parameter is either persistent or recoverable.
- * <code>false</code> otherwise.
- * @see com.arjuna.ats.arjuna.coordinator.RecordType
- */
-
- public boolean shouldReplace (AbstractRecord ar)
- {
- return (((order().equals(ar.order())) &&
- ((ar.typeIs() == RecordType.PERSISTENCE) ||
- (ar.typeIs() == RecordType.RECOVERY)))
- ? true : false);
- }
-
- /**
- * Create a new instance using default values. Typically used during
- * failure recovery.
- */
-
- public CadaverRecord ()
- {
- super();
-
- newStateIsValid = false;
- oldState = null;
- oType = RecordType.NONE_RECORD;
- store = null;
-
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PROTECTED,
- FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::CadaverRecord ()");
- }
- }
-
- private boolean newStateIsValid;
- private OutputObjectState oldState;
- private int oType;
- private ObjectStore store;
-
-}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java 2009-11-05 21:28:50 UTC (rev 30035)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -1,337 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000, 2001,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: DisposeRecord.java 2342 2006-03-30 13:06:17Z $
- */
-
-/*
- *
- * Dipose Record Class.
- *
- */
-
-package com.arjuna.ats.arjuna;
-
-import com.arjuna.ats.arjuna.logging.tsLogger;
-import com.arjuna.ats.arjuna.logging.FacilityCode;
-
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
-import com.arjuna.ats.internal.arjuna.common.UidHelper;
-
-import java.io.PrintWriter;
-
-import java.io.IOException;
-
-import com.arjuna.common.util.logging.*;
-
-public class DisposeRecord extends CadaverRecord
-{
-
- public DisposeRecord (ObjectStore objStore, StateManager sm)
- {
- super(null, objStore, sm);
-
- store = objStore;
-
- if (sm != null)
- {
- objectUid = sm.get_uid();
- typeName = sm.type();
- }
- else
- {
- objectUid = Uid.nullUid();
- typeName = null;
- }
-
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC,
- "DisposeRecord::DisposeRecord("+objStore+", "+objectUid+")");
- }
- }
-
- public boolean propagateOnAbort ()
- {
- return false;
- }
-
- public int typeIs ()
- {
- return RecordType.DISPOSE;
- }
-
- public int nestedAbort ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::nestedAbort() for "+order());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- public int nestedCommit ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::nestedCommit() for "+order());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- public int nestedPrepare ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::nestedPrepare() for "+order());
- }
-
- if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
- return TwoPhaseOutcome.PREPARE_OK;
- else
- return TwoPhaseOutcome.PREPARE_NOTOK;
- }
-
- public int topLevelAbort ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::topLevelAbort() for "+order());
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
-
- /**
- * At topLevelCommit we remove the state from the object store.
- *
- * @message com.arjuna.ats.arjuna.DisposeRecord_5 [com.arjuna.ats.arjuna.DisposeRecord_5] DisposeRecord::topLevelCommit - exception while deleting state {0}
- */
-
- public int topLevelCommit ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::topLevelCommit() for "+order());
- }
-
- if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
- {
- try
- {
- if (store.remove_committed(objectUid, typeName))
- {
- // only valid if not doing recovery
-
- if (super.objectAddr != null)
- {
- super.objectAddr.destroyed();
- }
-
- return TwoPhaseOutcome.FINISH_OK;
- }
- }
- catch (Exception e)
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_5",
- new Object[]{e});
- }
- }
- }
-
- return TwoPhaseOutcome.FINISH_ERROR;
- }
-
- public int topLevelPrepare ()
- {
- if (tsLogger.arjLogger.isDebugEnabled())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
- "DisposeRecord::topLevelPrepare() for "+order());
- }
-
- if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
- {
- return TwoPhaseOutcome.PREPARE_OK;
- }
- else
- return TwoPhaseOutcome.PREPARE_NOTOK;
- }
-
- public void print (PrintWriter strm)
- {
- strm.println("Dispose for:");
- super.print(strm);
- }
-
- public boolean doSave ()
- {
- return true;
- }
-
- /**
- * @message com.arjuna.ats.arjuna.DisposeRecord_1 [com.arjuna.ats.arjuna.DisposeRecord_1] DisposeRecord::save_state - type of store is unknown
- * @message com.arjuna.ats.arjuna.DisposeRecord_2 [com.arjuna.ats.arjuna.DisposeRecord_2] DisposeRecord::save_state - failed
- * @message com.arjuna.ats.arjuna.DisposeRecord_3 [com.arjuna.ats.arjuna.DisposeRecord_3] DisposeRecord::save_state - no object store defined.
- * @message com.arjuna.ats.arjuna.DisposeRecord_4 [com.arjuna.ats.arjuna.DisposeRecord_4] DisposeRecord::restore_state - invalid store type {0}
- */
-
- public boolean save_state (OutputObjectState os, int ot)
- {
- boolean res = true;
-
- if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
- {
- if (!ObjectStoreType.valid(store.typeIs()))
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_1");
-
- res = false;
- }
- else
- {
- try
- {
- os.packInt(store.typeIs());
- store.pack(os);
-
- UidHelper.packInto(objectUid, os);
- os.packString(typeName);
- }
- catch (IOException e)
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_2");
- res = false;
- }
- }
- }
- else
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_3");
-
- res = false;
- }
-
- return res;
- }
-
- @SuppressWarnings("unchecked")
- public boolean restore_state (InputObjectState os, int ot)
- {
- boolean res = true;
- int objStoreType = 0;
-
- try
- {
- objStoreType = os.unpackInt();
-
- if (ObjectStoreType.valid(objStoreType))
- {
- Class osc = ObjectStoreType.typeToClass(objStoreType);
-
- store = (ObjectStore) osc.newInstance();
- store.unpack(os);
-
- objectUid = UidHelper.unpackFrom(os);
- typeName = os.unpackString();
- }
- else
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_4",
- new Object[]{Integer.toString(objStoreType)});
- }
-
- res = false;
- }
- }
- catch (final Exception e)
- {
- res = false;
- }
-
- return res;
- }
-
- public String type ()
- {
- return "/StateManager/AbstractRecord/RecoveryRecord/PersistenceRecord/CadaverRecord/DisposeRecord";
- }
-
- public boolean shouldAdd (AbstractRecord a)
- {
- return false;
- }
-
- public boolean shouldMerge (AbstractRecord a)
- {
- return false;
- }
-
- public boolean shouldReplace (AbstractRecord a)
- {
- return false;
- }
-
- public boolean shouldAlter (AbstractRecord a)
- {
- return false;
- }
-
- public DisposeRecord ()
- {
- super();
-
- objectUid = new Uid(Uid.nullUid());
- typeName = null;
- store = null;
- }
-
- private Uid objectUid;
- private String typeName;
- private ObjectStore store;
-}
-
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/DisposeRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -0,0 +1,338 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000, 2001,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: DisposeRecord.java 2342 2006-03-30 13:06:17Z $
+ */
+
+/*
+ *
+ * Dipose Record Class.
+ *
+ */
+
+package com.arjuna.ats.arjuna;
+
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.arjuna.logging.FacilityCode;
+
+import com.arjuna.ats.arjuna.coordinator.*;
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.arjuna.state.*;
+import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord;
+import com.arjuna.ats.internal.arjuna.common.UidHelper;
+
+import java.io.PrintWriter;
+
+import java.io.IOException;
+
+import com.arjuna.common.util.logging.*;
+
+public class DisposeRecord extends CadaverRecord
+{
+
+ public DisposeRecord (ObjectStore objStore, StateManager sm)
+ {
+ super(null, objStore, sm);
+
+ store = objStore;
+
+ if (sm != null)
+ {
+ objectUid = sm.get_uid();
+ typeName = sm.type();
+ }
+ else
+ {
+ objectUid = Uid.nullUid();
+ typeName = null;
+ }
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "DisposeRecord::DisposeRecord("+objStore+", "+objectUid+")");
+ }
+ }
+
+ public boolean propagateOnAbort ()
+ {
+ return false;
+ }
+
+ public int typeIs ()
+ {
+ return RecordType.DISPOSE;
+ }
+
+ public int nestedAbort ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::nestedAbort() for "+order());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int nestedCommit ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::nestedCommit() for "+order());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int nestedPrepare ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::nestedPrepare() for "+order());
+ }
+
+ if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
+ return TwoPhaseOutcome.PREPARE_OK;
+ else
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ }
+
+ public int topLevelAbort ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::topLevelAbort() for "+order());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ /**
+ * At topLevelCommit we remove the state from the object store.
+ *
+ * @message com.arjuna.ats.arjuna.DisposeRecord_5 [com.arjuna.ats.arjuna.DisposeRecord_5] DisposeRecord::topLevelCommit - exception while deleting state {0}
+ */
+
+ public int topLevelCommit ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "DisposeRecord::topLevelCommit() for "+order());
+ }
+
+ if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
+ {
+ try
+ {
+ if (store.remove_committed(objectUid, typeName))
+ {
+ // only valid if not doing recovery
+
+ if (super.objectAddr != null)
+ {
+ super.objectAddr.destroyed();
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+ }
+ catch (Exception e)
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_5",
+ new Object[]{e});
+ }
+ }
+ }
+
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ public int topLevelPrepare ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "DisposeRecord::topLevelPrepare() for "+order());
+ }
+
+ if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
+ {
+ return TwoPhaseOutcome.PREPARE_OK;
+ }
+ else
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ }
+
+ public void print (PrintWriter strm)
+ {
+ strm.println("Dispose for:");
+ super.print(strm);
+ }
+
+ public boolean doSave ()
+ {
+ return true;
+ }
+
+ /**
+ * @message com.arjuna.ats.arjuna.DisposeRecord_1 [com.arjuna.ats.arjuna.DisposeRecord_1] DisposeRecord::save_state - type of store is unknown
+ * @message com.arjuna.ats.arjuna.DisposeRecord_2 [com.arjuna.ats.arjuna.DisposeRecord_2] DisposeRecord::save_state - failed
+ * @message com.arjuna.ats.arjuna.DisposeRecord_3 [com.arjuna.ats.arjuna.DisposeRecord_3] DisposeRecord::save_state - no object store defined.
+ * @message com.arjuna.ats.arjuna.DisposeRecord_4 [com.arjuna.ats.arjuna.DisposeRecord_4] DisposeRecord::restore_state - invalid store type {0}
+ */
+
+ public boolean save_state (OutputObjectState os, int ot)
+ {
+ boolean res = true;
+
+ if ((store != null) && (objectUid.notEquals(Uid.nullUid())))
+ {
+ if (!ObjectStoreType.valid(store.typeIs()))
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_1");
+
+ res = false;
+ }
+ else
+ {
+ try
+ {
+ os.packInt(store.typeIs());
+ store.pack(os);
+
+ UidHelper.packInto(objectUid, os);
+ os.packString(typeName);
+ }
+ catch (IOException e)
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_2");
+ res = false;
+ }
+ }
+ }
+ else
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_3");
+
+ res = false;
+ }
+
+ return res;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean restore_state (InputObjectState os, int ot)
+ {
+ boolean res = true;
+ int objStoreType = 0;
+
+ try
+ {
+ objStoreType = os.unpackInt();
+
+ if (ObjectStoreType.valid(objStoreType))
+ {
+ Class osc = ObjectStoreType.typeToClass(objStoreType);
+
+ store = (ObjectStore) osc.newInstance();
+ store.unpack(os);
+
+ objectUid = UidHelper.unpackFrom(os);
+ typeName = os.unpackString();
+ }
+ else
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.DisposeRecord_4",
+ new Object[]{Integer.toString(objStoreType)});
+ }
+
+ res = false;
+ }
+ }
+ catch (final Exception e)
+ {
+ res = false;
+ }
+
+ return res;
+ }
+
+ public String type ()
+ {
+ return "/StateManager/AbstractRecord/RecoveryRecord/PersistenceRecord/CadaverRecord/DisposeRecord";
+ }
+
+ public boolean shouldAdd (AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldMerge (AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldReplace (AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldAlter (AbstractRecord a)
+ {
+ return false;
+ }
+
+ public DisposeRecord ()
+ {
+ super();
+
+ objectUid = new Uid(Uid.nullUid());
+ typeName = null;
+ store = null;
+ }
+
+ private Uid objectUid;
+ private String typeName;
+ private ObjectStore store;
+}
+
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java 2009-11-05 21:28:50 UTC (rev 30035)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -46,6 +46,8 @@
import com.arjuna.ats.arjuna.logging.FacilityCode;
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord;
import com.arjuna.ats.internal.arjuna.common.UidHelper;
import java.io.IOException;
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordType.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordType.java 2009-11-05 21:28:50 UTC (rev 30035)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordType.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -35,12 +35,12 @@
import com.arjuna.ats.arjuna.coordinator.record.RecordTypeManager;
import com.arjuna.ats.arjuna.ActivationRecord;
-import com.arjuna.ats.arjuna.CadaverRecord;
import com.arjuna.ats.arjuna.DisposeRecord;
import com.arjuna.ats.arjuna.LastResourceRecord;
import com.arjuna.ats.arjuna.PersistenceRecord;
import com.arjuna.ats.arjuna.RecoveryRecord;
import com.arjuna.ats.internal.arjuna.TxLogWritePersistenceRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord;
/**
* The following enumerated type defines the types of record that are derived
Copied: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverActivationRecord.java (from rev 30032, labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverActivationRecord.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverActivationRecord.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverActivationRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: CadaverActivationRecord.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.internal.arjuna.abstractrecords;
+
+import com.arjuna.ats.arjuna.ActivationRecord;
+import com.arjuna.ats.arjuna.ObjectStatus;
+import com.arjuna.ats.arjuna.StateManager;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.arjuna.logging.FacilityCode;
+
+import com.arjuna.ats.arjuna.coordinator.*;
+
+import com.arjuna.common.util.logging.*;
+
+/*
+ * This constructor is used to create a new instance of an
+ * CadaverActivationRecord.
+ */
+
+public class CadaverActivationRecord extends ActivationRecord
+{
+
+ public CadaverActivationRecord (StateManager sm)
+ {
+ super(ObjectStatus.PASSIVE, sm, null);
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::CadaverActivationRecord(" +sm.get_uid()+")");
+ }
+ }
+
+ public boolean propagateOnAbort ()
+ {
+ return true;
+ }
+
+ /*
+ * Supress all atomic action ops for deleted object
+ */
+
+ public int nestedAbort ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::nestedAbort() for "+get_uid());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int nestedCommit ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::nestedCommit() for "+get_uid());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int nestedPrepare ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::nestedPrepare() for "+get_uid());
+ }
+
+ return TwoPhaseOutcome.PREPARE_READONLY;
+ }
+
+ public int topLevelAbort ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::topLevelAbort() for "+get_uid());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int topLevelCommit ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::topLevelCommit() for "+get_uid());
+ }
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int topLevelPrepare ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::topLevelPrepare() for "+get_uid());
+ }
+
+ return TwoPhaseOutcome.PREPARE_READONLY;
+ }
+
+ public String type ()
+ {
+ return "/StateManager/AbstractRecord/CadaverActivationRecord";
+ }
+
+ /*
+ * shouldMerge and should_replace are invoked by the record list manager
+ * to determine if two records should be merged togethor or if the
+ * 'newer' should replace the older.
+ * shouldAdd determines if the new record should be added in addition
+ * to the existing record and is currently only invoked if both of
+ * shouldMerge and shouldReplace return false
+ * Default implementations here always return false - ie new records
+ * do not override old
+ */
+
+ public boolean shouldReplace (AbstractRecord ar)
+ {
+ return (((order().equals(ar.order())) &&
+ ar.typeIs() == RecordType.ACTIVATION ) ? true : false);
+ }
+
+ protected CadaverActivationRecord ()
+ {
+ super();
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PROTECTED,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverActivationRecord::CadaverActivationRecord ()");
+ }
+ }
+
+}
Copied: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java (from rev 30034, labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/CadaverRecord.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java 2009-11-05 21:36:20 UTC (rev 30036)
@@ -0,0 +1,442 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000, 2001,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: CadaverRecord.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.internal.arjuna.abstractrecords;
+
+import com.arjuna.ats.arjuna.PersistenceRecord;
+import com.arjuna.ats.arjuna.StateManager;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.arjuna.logging.FacilityCode;
+
+import com.arjuna.ats.arjuna.coordinator.*;
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+import com.arjuna.ats.arjuna.state.*;
+import java.io.PrintWriter;
+
+import com.arjuna.common.util.logging.*;
+
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+
+/**
+ * Cadaver records are created whenever a persistent object is deleted while
+ * still in the scope of an atomic action. This ensures that if the
+ * action commits the state of the persistent objects gets properly
+ * reflected back in the object store. For objects that are only
+ * recoverable such work is unnecessary. Cadaver records replace
+ * PersistenceRecords in the record list of an atomic action so they must
+ * be merged with such records to enable both commits and aborts to occur.
+ *
+ * @author Mark Little (mark at arjuna.com)
+ * @version $Id: CadaverRecord.java 2342 2006-03-30 13:06:17Z $
+ * @since JTS 1.0.
+ */
+
+public class CadaverRecord extends PersistenceRecord
+{
+
+ /**
+ * Create a new instance, passing in the object that is being managed.
+ *
+ * @param os the state of the object that is being
+ * removed.
+ * @param objStore the object store instance used to manipulate the
+ * persistent state.
+ * @param sm the object being removed.
+ */
+
+ public CadaverRecord (OutputObjectState os, ObjectStore objStore,
+ StateManager sm)
+ {
+ super(os, objStore, sm);
+
+ newStateIsValid = ((os != null) ? true : false);
+ oldState = null;
+ oType = RecordType.NONE_RECORD;
+ store = objStore; // implicit ref count in Java
+
+ if (store != null)
+ {
+ /*
+ * If the object goes out of scope its object store may
+ * be inaccessable - increase reference count to compensate
+ */
+
+ /*
+ * Don't need this in Java.
+ */
+
+ // ObjectStore.reference(store);
+ }
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC,
+ "CadaverRecord::CadaverRecord("+os+", "+sm.get_uid()+")");
+ }
+ }
+
+ /**
+ * Override default AbstractRecord method. CadaverRecords are propagated
+ * regardless of the termination condition.
+ *
+ * @return <code>true</code>
+ */
+
+ public boolean propagateOnAbort ()
+ {
+ return true;
+ }
+
+ /**
+ * The type of the record.
+ *
+ * @return RecordType.PERSISTENT
+ * @see com.arjuna.ats.arjuna.coordinator.RecordType
+ */
+
+ public int typeIs ()
+ {
+ return RecordType.PERSISTENCE;
+ }
+
+ /**
+ * The nested transaction has aborted. The record will invalidate any
+ * new state.
+ *
+ * @message com.arjuna.ats.arjuna.CadaverRecord_1 [com.arjuna.ats.arjuna.CadaverRecord_1] Attempted abort operation on deleted object id {0} of type {1} ignored
+ */
+
+ public int nestedAbort ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::nestedAbort() for "+order());
+ }
+
+ if (oldState != null)
+ newStateIsValid = false;
+
+ if (oType == RecordType.RECOVERY)
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.CadaverRecord_1",
+ new Object[]{ order(), getTypeOfObject() } );
+ }
+ }
+
+ /*
+ * No need to forget the action since this object is
+ * being deleted so it is unlikely to have modified called
+ * on it!
+ */
+
+ // super.forgetAction(false);
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ /**
+ * The nested transaction is preparing. If there is any new state for
+ * the object being removed, and that state is valid, then this record
+ * will call nestedPrepare on the object being removed.
+ *
+ * If we have no new state then we cannot commit and must force an
+ * abort. Do this by failing the prepare phase.
+ */
+
+ public int nestedPrepare ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::nestedPrepare() for "+order());
+ }
+
+ if (newStateIsValid)
+ return super.nestedPrepare();
+ else
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ }
+
+ /**
+ * The nested transaction has aborted. Invalidate any new state.
+ */
+
+ public int topLevelAbort ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::topLevelAbort() for "+order());
+ }
+
+ newStateIsValid = false;
+
+ if (oType == RecordType.RECOVERY)
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.CadaverRecord_1",
+ new Object[]{ order(), getTypeOfObject() } );
+ }
+ }
+
+ // super.forgetAction(false);
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ /**
+ * At topLevelCommit we commit the uncommitted version already saved
+ * into object store.
+ * Cannot use inherited version since that assumes object is alive
+ * instead talk directly to the object store itself.
+ */
+
+ public int topLevelCommit ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::topLevelCommit() for "+order());
+ }
+
+ boolean res = true;
+ OutputObjectState oState = super.state;
+
+ if ((oState != null) && (oType == RecordType.PERSISTENCE))
+ {
+ if (store == null)
+ return TwoPhaseOutcome.FINISH_ERROR;
+
+ try
+ {
+ res = store.commit_state(oState.stateUid(), oState.type());
+ }
+ catch (ObjectStoreException e)
+ {
+ res = false;
+ }
+ }
+
+ // super.forgetAction(false);
+
+ return ((res) ? TwoPhaseOutcome.FINISH_OK : TwoPhaseOutcome.FINISH_ERROR);
+ }
+
+ /**
+ * At topLevelPrepare write uncommitted version into object store.
+ * Cannot use inherited version since that assumes object is alive
+ * instead talk directly to the object store itself.
+ */
+
+ public int topLevelPrepare ()
+ {
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::topLevelPrepare() for "+order());
+ }
+
+ int tlpOk = TwoPhaseOutcome.PREPARE_NOTOK;
+ OutputObjectState oState = (newStateIsValid ? super.state : oldState);
+
+ if (oState != null)
+ {
+ if (oType == RecordType.PERSISTENCE)
+ {
+ if (store == null)
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+
+ try
+ {
+ if (store.write_uncommitted(oState.stateUid(), oState.type(), oState))
+ {
+ if (shadowForced())
+ tlpOk = TwoPhaseOutcome.PREPARE_OK;
+ }
+ }
+ catch (ObjectStoreException e)
+ {
+ }
+ }
+ else
+ tlpOk = TwoPhaseOutcome.PREPARE_OK;
+ }
+
+ return tlpOk;
+ }
+
+ /**
+ * Override AbstractRecord.print to write specific information to
+ * the specified stream.
+ *
+ * @param strm the stream to use.
+ */
+
+ public void print (PrintWriter strm)
+ {
+ strm.println("Cadaver for:");
+ super.print(strm);
+ }
+
+ /**
+ * The type of the class - may be used to save information in an
+ * hierarchical manner in the object store.
+ */
+
+ public String type()
+ {
+ return "/StateManager/AbstractRecord/RecoveryRecord/PersistenceRecord/CadaverRecord";
+ }
+
+ /**
+ * Override the AbstractRecord.doSave.
+ *
+ * @return <code>true</code> if the object being removed is a persistent
+ * object (RecordType.PERSISTENT). <code>false</code> otherwise.
+ * @see com.arjuna.ats.arjuna.coordinator.RecordType
+ */
+
+ public boolean doSave ()
+ {
+ if (oType == RecordType.PERSISTENCE)
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * merge takes the information from the incoming PersistenceRecord and
+ * uses it to initialise the oldState information. This is required
+ * for processing of action aborts since CadaverRecords maintain the
+ * final state of an object normally - which is required if the action
+ * commits.
+ *
+ * @param mergewith The record to merge with.
+ */
+
+ public void merge (AbstractRecord mergewith)
+ {
+ /*
+ * Following assumes that value returns a pointer to the
+ * old state maintained in the PersistenceRecord (as an ObjectState).
+ * Here we create a copy of that state allowing the original
+ * to be deleted
+ */
+
+ oType = mergewith.typeIs();
+
+ if (oldState != null)
+ {
+ if (newStateIsValid)
+ {
+ oldState = null;
+ }
+ else
+ {
+ setValue(oldState);
+ newStateIsValid = true;
+ }
+ }
+
+ oldState = new OutputObjectState((OutputObjectState)(mergewith.value()));
+ }
+
+ /**
+ * Overrides AbstractRecord.shouldMerge
+ *
+ * @param ar the record to potentially merge with.
+ *
+ * @return <code>true</code> if this instance and the parameter have the
+ * same id (order()) and the parameter is either persistent or recoverable.
+ * <code>false</code> otherwise.
+ * @see com.arjuna.ats.arjuna.coordinator.RecordType
+ */
+
+ public boolean shouldMerge (AbstractRecord ar)
+ {
+ return (((order().equals(ar.order())) &&
+ ((ar.typeIs() == RecordType.PERSISTENCE) ||
+ (ar.typeIs() == RecordType.RECOVERY)))
+ ? true : false);
+ }
+
+ /**
+ * Overrides AbstractRecord.shouldReplace
+ *
+ * @param ar the record to potentially replace this
+ * instance.
+ *
+ * @return <code>true</code> if this instance and the parameter have the
+ * same id (order()) and the parameter is either persistent or recoverable.
+ * <code>false</code> otherwise.
+ * @see com.arjuna.ats.arjuna.coordinator.RecordType
+ */
+
+ public boolean shouldReplace (AbstractRecord ar)
+ {
+ return (((order().equals(ar.order())) &&
+ ((ar.typeIs() == RecordType.PERSISTENCE) ||
+ (ar.typeIs() == RecordType.RECOVERY)))
+ ? true : false);
+ }
+
+ /**
+ * Create a new instance using default values. Typically used during
+ * failure recovery.
+ */
+
+ public CadaverRecord ()
+ {
+ super();
+
+ newStateIsValid = false;
+ oldState = null;
+ oType = RecordType.NONE_RECORD;
+ store = null;
+
+ if (tsLogger.arjLogger.isDebugEnabled())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PROTECTED,
+ FacilityCode.FAC_ABSTRACT_REC, "CadaverRecord::CadaverRecord ()");
+ }
+ }
+
+ private boolean newStateIsValid;
+ private OutputObjectState oldState;
+ private int oType;
+ private ObjectStore store;
+
+}
More information about the jboss-svn-commits
mailing list