/* This file is part of VoltDB.
 * Copyright (C) 2008-2010 VoltDB L.L.C.
 *
 * VoltDB is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VoltDB is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VoltDB.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.voltdb.dtxn;

import org.voltdb.ExecutionSite;
import org.voltdb.debugstate.ExecutorContext.ExecutorTxnState;
import org.voltdb.messages.*;
import org.voltdb.messaging.Mailbox;
import org.voltdb.messaging.MessagingException;

public class SinglePartitionTxnState extends TransactionState {

    InitiateTask m_task = null;

    public SinglePartitionTxnState(Mailbox mbox,
                                   ExecutionSite site,
                                   InitiateTask task)
    {
        super(mbox, site, task);
        m_task = task;
    }

    @Override
    public boolean doWork() {
        if (m_done)
            return true;

        m_site.beginNewTxn(m_task.getTxnId(), isReadOnly);
        InitiateResponse response = m_site.processInitiateTask(m_task);
        if (response.shouldCommit() == false) {
            // check if we need to undo
            if (!isReadOnly) {
                m_site.rollbackTransaction(isReadOnly);
            }
        }

        try {
            m_mbox.send(initiatorSiteId, 0, response);
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
        m_done = true;
        return true;
    }

    @Override
    public void getDumpContents(StringBuilder sb) {
        sb.append("  Single Partition Txn State with id ").append(txnId);
    }

    @Override
    public ExecutorTxnState getDumpContents() {
        ExecutorTxnState retval = new ExecutorTxnState();
        retval.txnId = txnId;
        retval.coordinatorSiteId = coordinatorSiteId;
        retval.initiatorSiteId = initiatorSiteId;
        retval.isReadOnly = isReadOnly;
        retval.nonCoordinatingSites = null;
        retval.procedureIsAborting = false;
        return retval;
    }
}

@@ -1325,42 +1325,23 @@
 if (
+!
 m_done)
+ %7B
 %0A    
-        return true;%0A%0A
     
@@ -1387,32 +1387,36 @@
 ), isReadOnly);%0A
+    
         Initiate
@@ -1475,24 +1475,28 @@
 k);%0A        
+  
+  
 if (response
@@ -1531,44 +1531,8 @@
     
-        // check if we need to undo%0A
     
@@ -1554,24 +1554,28 @@
 ReadOnly) %7B%0A
+    
             
@@ -1622,32 +1622,36 @@
 y);%0A            
+    
 %7D%0A        %7D%0A%0A   
@@ -1640,27 +1640,35 @@
   %7D%0A        
+ 
-%7D%0A%0A
+   %7D%0A%0A    
         try 
@@ -1669,16 +1669,20 @@
   try %7B%0A
+    
         
@@ -1724,24 +1724,28 @@
  response);%0A
+    
         %7D ca
@@ -1785,16 +1785,20 @@
         
+    
 throw ne
@@ -1816,24 +1816,28 @@
 ception(e);%0A
+    
         %7D%0A  
@@ -1842,16 +1842,20 @@
         
+    
 m_done =
@@ -1857,24 +1857,34 @@
 one = true;%0A
+        %7D%0A
         retu
@@ -1886,19 +1886,21 @@
  return 
-tru
+m_don
 e;%0A    %7D

Return m_done from doWork(), to make the semantic of the boolean return value clearer.