[jboss-svn-commits] JBL Code SVN: r35302 - labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Sep 26 16:51:24 EDT 2010
Author: mark.little at jboss.com
Date: 2010-09-26 16:51:24 -0400 (Sun, 26 Sep 2010)
New Revision: 35302
Added:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/TransactionTypeManager.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogBrowser.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogEditor.java
Log:
https://jira.jboss.org/browse/JBTM-699
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogBrowser.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogBrowser.java 2010-09-26 17:57:41 UTC (rev 35301)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogBrowser.java 2010-09-26 20:51:24 UTC (rev 35302)
@@ -23,15 +23,13 @@
import java.io.IOException;
-import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
import com.arjuna.ats.arjuna.objectstore.ObjectStoreIterator;
import com.arjuna.ats.arjuna.objectstore.StoreManager;
import com.arjuna.ats.arjuna.state.InputObjectState;
import com.arjuna.ats.internal.arjuna.common.UidHelper;
-import com.arjuna.ats.internal.arjuna.tools.log.EditableAtomicAction;
+import com.arjuna.ats.internal.arjuna.tools.log.EditableTransaction;
/**
* Commands:
@@ -50,15 +48,10 @@
* @author marklittle
*/
-/*
- * WARNING: this currently only supports AtomicActions.
- * TODO make it support all other transaction types!
- */
-
class LogConsole
{
public static final int MAX_COMMAND_LEN = 1024; // bytes
- public static final String DEFAULT_TYPE = new AtomicAction().type();
+ public static final String DEFAULT_TYPE = "AtomicAction";
private enum Command
{
@@ -167,7 +160,7 @@
System.err.println("Not attached.");
Uid u = new Uid(_currentLog);
- EditableAtomicAction act = new EditableAtomicAction(u);
+ EditableTransaction act = TransactionTypeManager.getInstance().getTransaction(_transactionType, u);
try
{
@@ -185,7 +178,7 @@
System.err.println("Not attached.");
Uid uid = new Uid(_currentLog);
- EditableAtomicAction ract = new EditableAtomicAction(uid);
+ EditableTransaction ract = TransactionTypeManager.getInstance().getTransaction(_transactionType, uid);
try
{
@@ -217,19 +210,12 @@
private void dumpLog (final Uid u)
{
- EditableAtomicAction act = new EditableAtomicAction(u);
+ EditableTransaction act = TransactionTypeManager.getInstance().getTransaction(_transactionType, u);
- System.out.println(act.toString());
- }
-
- // should accept AtomicAction instead of /StateManager/../AtomicAction
-
- private boolean supportedType (String type) // need more supported types!
- {
- if (DEFAULT_TYPE.endsWith(type))
- return true;
+ if (act == null)
+ System.out.println("Dump failed! Unknown type "+_transactionType);
else
- return false;
+ System.out.println(act.toString());
}
private void printSupportedTypes ()
@@ -298,8 +284,12 @@
else
_transactionType = DEFAULT_TYPE;
- if (!supportedType(_transactionType))
+ if (!TransactionTypeManager.getInstance().present(_transactionType))
+ {
+ System.err.println("Transaction log type "+_transactionType+" not supported.");
+
_transactionType = "";
+ }
}
private final void setLogId (String command)
@@ -338,6 +328,10 @@
return -1;
}
+ /*
+ * Go through the log and print out all of the instances.
+ */
+
private final void listLogs (String type) throws IOException
{
InputObjectState buff = new InputObjectState();
@@ -366,9 +360,13 @@
}
}
- private final boolean supportedLog (String log)
+ /*
+ * Is this a type/instance in the log that we support?
+ */
+
+ private final boolean supportedLog (String logID)
{
- Uid id = new Uid(log);
+ Uid id = new Uid(logID);
if (id.equals(Uid.nullUid()))
return false;
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogEditor.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogEditor.java 2010-09-26 17:57:41 UTC (rev 35301)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/LogEditor.java 2010-09-26 20:51:24 UTC (rev 35302)
@@ -21,83 +21,10 @@
package com.arjuna.ats.arjuna.tools.log;
-import java.util.HashMap;
-
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.internal.arjuna.tools.log.EditableAtomicAction;
import com.arjuna.ats.internal.arjuna.tools.log.EditableTransaction;
-/**
- * Only allows the movement of heuristic participants to the prepared list.
- * Maybe allow general editing of both lists, including bidirectional movement (point?)
- * and deletion.
- */
-interface TransactionTypeMap
-{
- public EditableTransaction getTransaction (final Uid u);
- public String getType ();
-}
-
-class AtomicActionTypeMap implements TransactionTypeMap
-{
- public EditableTransaction getTransaction (final Uid u)
- {
- return new EditableAtomicAction(u);
- }
-
- public String getType ()
- {
- return "AtomicAction"; // why not Class name?
- }
-}
-
-class TransactionTypeManager
-{
- public EditableTransaction getTransaction (final String type, final Uid u)
- {
- if (type == null)
- throw new IllegalArgumentException();
-
- TransactionTypeMap map = _maps.get(type);
-
- if (map != null)
- return map.getTransaction(u);
- else
- return null;
- }
-
- public void addTransaction (TransactionTypeMap map)
- {
- if (map == null)
- throw new IllegalArgumentException();
-
- _maps.put(map.getType(), map);
- }
-
- public void removeTransaction (String type)
- {
- if (type == null)
- throw new IllegalArgumentException();
-
- _maps.remove(type);
- }
-
- public static TransactionTypeManager getInstance ()
- {
- return _manager;
- }
-
- private TransactionTypeManager ()
- {
- }
-
- private HashMap<String, TransactionTypeMap> _maps = new HashMap<String, TransactionTypeMap>();
-
- private static final TransactionTypeManager _manager = new TransactionTypeManager();
-}
-
-
public class LogEditor
{
public static final void main (String[] args)
@@ -140,8 +67,7 @@
return;
}
-
- TransactionTypeManager.getInstance().addTransaction(new AtomicActionTypeMap());
+
EditableTransaction act = TransactionTypeManager.getInstance().getTransaction(type, new Uid(txId));
System.err.println("Recreated transaction.");
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/TransactionTypeManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/TransactionTypeManager.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/log/TransactionTypeManager.java 2010-09-26 20:51:24 UTC (rev 35302)
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+package com.arjuna.ats.arjuna.tools.log;
+
+import java.util.HashMap;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.arjuna.tools.log.EditableAtomicAction;
+import com.arjuna.ats.internal.arjuna.tools.log.EditableTransaction;
+
+/*
+ * A default implementation for the default logstore.
+ */
+
+class AtomicActionTypeMap implements TransactionTypeManager.TransactionTypeMap
+{
+ public EditableTransaction getTransaction (final Uid u)
+ {
+ return new EditableAtomicAction(u);
+ }
+
+ public String getType ()
+ {
+ return "AtomicAction"; // why not Class name?
+ }
+}
+
+public class TransactionTypeManager
+{
+ /**
+ * Only allows the movement of heuristic participants to the prepared list.
+ * Maybe allow general editing of both lists, including bidirectional
+ * movement (point?) and deletion.
+ */
+
+ public interface TransactionTypeMap
+ {
+ public EditableTransaction getTransaction (final Uid u);
+
+ public String getType ();
+ }
+
+ public EditableTransaction getTransaction (final String type, final Uid u)
+ {
+ if (type == null)
+ throw new IllegalArgumentException();
+
+ TransactionTypeMap map = _maps.get(type);
+
+ if (map != null)
+ return map.getTransaction(u);
+ else
+ return null;
+ }
+
+ /**
+ * Is this transaction log one we support?
+ *
+ * @param type the name of the log.
+ * @return true if supported, false otherwise.
+ */
+
+ public boolean present (final String type)
+ {
+ return (_maps.get(type) != null);
+ }
+
+ public void addTransaction (TransactionTypeMap map)
+ {
+ if (map == null)
+ throw new IllegalArgumentException();
+
+ _maps.put(map.getType(), map);
+ }
+
+ public void removeTransaction (String type)
+ {
+ if (type == null)
+ throw new IllegalArgumentException();
+
+ _maps.remove(type);
+ }
+
+ public static TransactionTypeManager getInstance ()
+ {
+ return _manager;
+ }
+
+ private TransactionTypeManager()
+ {
+ addTransaction(new AtomicActionTypeMap());
+ }
+
+ private HashMap<String, TransactionTypeMap> _maps = new HashMap<String, TransactionTypeMap>();
+
+ private static final TransactionTypeManager _manager = new TransactionTypeManager();
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list