replaced TransactionResourceRepository with IndexLifeCycleManager

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1128 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java
index 86a8c6e..ad1bcc8 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java
@@ -58,7 +58,7 @@
 import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
 import edu.uci.ics.asterix.transaction.management.opcallbacks.PrimaryIndexModificationOperationCallback;
 import edu.uci.ics.asterix.transaction.management.opcallbacks.SecondaryIndexModificationOperationCallback;
-import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceRepository;
+import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceManagerRepository;
 import edu.uci.ics.asterix.transaction.management.service.transaction.DatasetId;
 import edu.uci.ics.asterix.transaction.management.service.transaction.DatasetIdFactory;
 import edu.uci.ics.asterix.transaction.management.service.transaction.IResourceManager.ResourceType;
@@ -282,13 +282,6 @@
     private IModificationOperationCallback createIndexModificationCallback(JobId jobId, long resourceId,
             IMetadataIndex metadataIndex, ILSMIndex lsmIndex, IndexOperation indexOp) throws Exception {
         TransactionContext txnCtx = transactionSubsystem.getTransactionManager().getTransactionContext(jobId);
-        TransactionalResourceRepository txnResourceRepository = transactionSubsystem
-                .getTransactionalResourceRepository();
-
-        if (txnResourceRepository.getTransactionalResource(resourceId) == null) {
-            transactionSubsystem.getTransactionalResourceRepository().registerTransactionalResource(resourceId,
-                    lsmIndex);
-        }
 
         int[] primaryKeyFields = metadataIndex.getPrimaryKeyIndexes();
         int numKeys = primaryKeyFields.length;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataIndex.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataIndex.java
index 9fe43fb..ca6ab08 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataIndex.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataIndex.java
@@ -68,16 +68,12 @@
 
     public void setFileId(int fileId);
 
-    public void initIndexLogger(IIndex index) throws ACIDException;
-
     public int getFileId();
 
     public void setResourceID(long resourceID);
 
     public long getResourceID();
 
-    public IndexLogger getIndexLogger();
-
     public DatasetId getDatasetId();
 
     boolean isPrimaryIndex();
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
index 3fa891a..35dae4d 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -53,7 +53,7 @@
 import edu.uci.ics.asterix.transaction.management.resource.ILocalResourceMetadata;
 import edu.uci.ics.asterix.transaction.management.resource.LSMBTreeLocalResourceMetadata;
 import edu.uci.ics.asterix.transaction.management.resource.PersistentLocalResourceFactoryProvider;
-import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceRepository;
+import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceManagerRepository;
 import edu.uci.ics.asterix.transaction.management.service.logging.IndexResourceManager;
 import edu.uci.ics.asterix.transaction.management.service.transaction.IResourceManager.ResourceType;
 import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionManagementConstants.LockManagerConstants.LockMode;
@@ -137,7 +137,7 @@
         initLocalIndexArrays();
 
         boolean isNewUniverse = true;
-        TransactionalResourceRepository resourceRepository = runtimeContext.getTransactionSubsystem()
+        TransactionalResourceManagerRepository resourceRepository = runtimeContext.getTransactionSubsystem()
                 .getTransactionalResourceRepository();
         resourceRepository.registerTransactionalResourceManager(ResourceType.LSM_BTREE, new IndexResourceManager(
                 ResourceType.LSM_BTREE, runtimeContext.getTransactionSubsystem()));
@@ -174,11 +174,9 @@
 
                 for (int i = 0; i < primaryIndexes.length; i++) {
                     enlistMetadataDataset(primaryIndexes[i], true);
-                    registerTransactionalResource(primaryIndexes[i], resourceRepository);
                 }
                 for (int i = 0; i < secondaryIndexes.length; i++) {
                     enlistMetadataDataset(secondaryIndexes[i], true);
-                    registerTransactionalResource(secondaryIndexes[i], resourceRepository);
                 }
                 insertInitialDataverses(mdTxnCtx);
                 insertInitialDatasets(mdTxnCtx);
@@ -198,11 +196,9 @@
         } else {
             for (int i = 0; i < primaryIndexes.length; i++) {
                 enlistMetadataDataset(primaryIndexes[i], false);
-                registerTransactionalResource(primaryIndexes[i], resourceRepository);
             }
             for (int i = 0; i < secondaryIndexes.length; i++) {
                 enlistMetadataDataset(secondaryIndexes[i], false);
-                registerTransactionalResource(secondaryIndexes[i], resourceRepository);
             }
             LOGGER.info("FINISHED ENLISTMENT OF METADATA B-TREES.");
         }
@@ -225,14 +221,6 @@
         }
     }
 
-    private static void registerTransactionalResource(IMetadataIndex metadataIndex,
-            TransactionalResourceRepository resourceRepository) throws ACIDException {
-        long resourceId = metadataIndex.getResourceID();
-        IIndex index = indexLifecycleManager.getIndex(resourceId);
-        resourceRepository.registerTransactionalResource(resourceId, index);
-        metadataIndex.initIndexLogger(index);
-    }
-
     public static void insertInitialDataverses(MetadataTransactionContext mdTxnCtx) throws Exception {
         String dataverseName = MetadataPrimaryIndexes.DATAVERSE_DATASET.getDataverseName();
         String dataFormat = NonTaggedDataFormat.NON_TAGGED_DATA_FORMAT;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataIndex.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataIndex.java
index 2bc9f4f..c0ce030 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataIndex.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataIndex.java
@@ -71,8 +71,6 @@
     protected int fileId;
     // Resource id of this index for use in transactions.
     protected long resourceId;
-    // Logger for tree indexes.
-    private IndexLogger indexLogger;
     // datasetId
     private final DatasetId datasetId;
     // Flag of primary index
@@ -235,11 +233,6 @@
     }
 
     @Override
-    public void initIndexLogger(IIndex index) throws ACIDException {
-        this.indexLogger = new IndexLogger(resourceId, ResourceType.LSM_BTREE, index);
-    }
-
-    @Override
     public int getFileId() {
         return fileId;
     }
@@ -249,10 +242,6 @@
         return payloadType;
     }
 
-    public IndexLogger getIndexLogger() {
-        return indexLogger;
-    }
-
     @Override
     public void setFile(FileReference file) {
         this.file = file;
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexModificationOperationCallbackFactory.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexModificationOperationCallbackFactory.java
index af1cb9d..f3dee0c 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexModificationOperationCallbackFactory.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexModificationOperationCallbackFactory.java
@@ -16,7 +16,7 @@
 package edu.uci.ics.asterix.transaction.management.opcallbacks;
 
 import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
-import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceRepository;
+import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceManagerRepository;
 import edu.uci.ics.asterix.transaction.management.service.transaction.ITransactionSubsystemProvider;
 import edu.uci.ics.asterix.transaction.management.service.transaction.JobId;
 import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionContext;
@@ -24,6 +24,7 @@
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.storage.am.common.api.IIndexLifecycleManager;
 import edu.uci.ics.hyracks.storage.am.common.api.IModificationOperationCallback;
 import edu.uci.ics.hyracks.storage.am.common.api.IModificationOperationCallbackFactory;
 import edu.uci.ics.hyracks.storage.am.common.ophelpers.IndexOperation;
@@ -48,14 +49,13 @@
     @Override
     public IModificationOperationCallback createModificationOperationCallback(long resourceId, Object resource,
             IHyracksTaskContext ctx) throws HyracksDataException {
-        TransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
-        TransactionalResourceRepository txnResourceRepository = txnSubsystem.getTransactionalResourceRepository();
-        ILSMIndex index = (ILSMIndex) txnResourceRepository.getTransactionalResource(resourceId);
 
-        //register the resource if it is not registered
+        TransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
+        IIndexLifecycleManager indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider()
+                .getIndexLifecycleManager();
+        ILSMIndex index = (ILSMIndex) indexLifeCycleManager.getIndex(resourceId);
         if (index == null) {
-            txnSubsystem.getTransactionalResourceRepository().registerTransactionalResource(resourceId, resource);
-            index = (ILSMIndex) resource;
+            throw new HyracksDataException("Index(id:"+resourceId+") is not registered.");
         }
 
         try {
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexModificationOperationCallbackFactory.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexModificationOperationCallbackFactory.java
index 3fede95..49f74bd 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexModificationOperationCallbackFactory.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexModificationOperationCallbackFactory.java
@@ -16,7 +16,7 @@
 package edu.uci.ics.asterix.transaction.management.opcallbacks;
 
 import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
-import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceRepository;
+import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceManagerRepository;
 import edu.uci.ics.asterix.transaction.management.service.transaction.ITransactionSubsystemProvider;
 import edu.uci.ics.asterix.transaction.management.service.transaction.JobId;
 import edu.uci.ics.asterix.transaction.management.service.transaction.TransactionContext;
@@ -24,6 +24,7 @@
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.storage.am.common.api.IIndexLifecycleManager;
 import edu.uci.ics.hyracks.storage.am.common.api.IModificationOperationCallback;
 import edu.uci.ics.hyracks.storage.am.common.api.IModificationOperationCallbackFactory;
 import edu.uci.ics.hyracks.storage.am.common.ophelpers.IndexOperation;
@@ -45,14 +46,13 @@
     @Override
     public IModificationOperationCallback createModificationOperationCallback(long resourceId, Object resource, IHyracksTaskContext ctx)
             throws HyracksDataException {
+        
         TransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
-        TransactionalResourceRepository txnResourceRepository = txnSubsystem.getTransactionalResourceRepository();
-        ILSMIndex index = (ILSMIndex) txnResourceRepository.getTransactionalResource(resourceId);
-
-        //register the resource if it is not registered
+        IIndexLifecycleManager indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider()
+                .getIndexLifecycleManager();
+        ILSMIndex index = (ILSMIndex) indexLifeCycleManager.getIndex(resourceId);
         if (index == null) {
-            txnSubsystem.getTransactionalResourceRepository().registerTransactionalResource(resourceId, resource);
-            index = (ILSMIndex) resource;
+            throw new HyracksDataException("Index(id:"+resourceId+") is not registered.");
         }
         
         try {
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/TransactionalResourceRepository.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/TransactionalResourceManagerRepository.java
similarity index 61%
rename from asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/TransactionalResourceRepository.java
rename to asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/TransactionalResourceManagerRepository.java
index 4532390..d38226b 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/TransactionalResourceRepository.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/TransactionalResourceManagerRepository.java
@@ -15,12 +15,10 @@
 
 package edu.uci.ics.asterix.transaction.management.resource;
 
-import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Map;
 
 import edu.uci.ics.asterix.transaction.management.service.transaction.IResourceManager;
-import edu.uci.ics.asterix.transaction.management.service.transaction.MutableResourceId;
 
 /**
  * Represents a repository containing Resource Managers and Resources in the
@@ -31,25 +29,9 @@
  * recovery. An example of resource is a @see ITreeIndex that is managed by a
  * resource manager @see TreeResourceManager
  */
-public class TransactionalResourceRepository {
-
-    private Map<MutableResourceId, Object> resourceRepository = new HashMap<MutableResourceId, Object>(); // repository
+public class TransactionalResourceManagerRepository {
 
     private Map<Byte, IResourceManager> resourceMgrRepository = new HashMap<Byte, IResourceManager>(); // repository
-    
-    private MutableResourceId mutableResourceId = new MutableResourceId(0);
-
-    public void registerTransactionalResource(long resourceId, Object resource) {
-        synchronized (resourceRepository) {
-            mutableResourceId.setId(resourceId);
-//            MutableResourceId newMutableResourceId = new MutableResourceId(resourceId);
-//            resourceRepository.put(newMutableResourceId, resource);
-            if (resourceRepository.get(resourceId) == null) {
-                MutableResourceId newMutableResourceId = new MutableResourceId(resourceId);
-                resourceRepository.put(newMutableResourceId, resource);
-            }
-        }
-    }
 
     public void registerTransactionalResourceManager(byte id, IResourceManager resourceMgr) {
         synchronized (resourceMgrRepository) {
@@ -59,13 +41,6 @@
         }
     }
 
-    public Object getTransactionalResource(long resourceId) {
-        synchronized (resourceRepository) {
-            mutableResourceId.setId(resourceId);
-            return resourceRepository.get(mutableResourceId);
-        }
-    }
-
     public IResourceManager getTransactionalResourceMgr(byte id) {
         synchronized (resourceMgrRepository) {
             return resourceMgrRepository.get(id);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexLoggerRepository.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexLoggerRepository.java
index 7eefe37..da5042c 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexLoggerRepository.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexLoggerRepository.java
@@ -24,11 +24,11 @@
 public class IndexLoggerRepository {
 
     private final Map<MutableResourceId, IndexLogger> loggers = new HashMap<MutableResourceId, IndexLogger>();
-    private final TransactionSubsystem provider;
+    private final TransactionSubsystem txnSubsystem;
     private MutableResourceId mutableResourceId;
 
     public IndexLoggerRepository(TransactionSubsystem provider) {
-        this.provider = provider;
+        this.txnSubsystem = provider;
         mutableResourceId = new MutableResourceId(0);
     }
 
@@ -37,7 +37,8 @@
         IndexLogger logger = loggers.get(mutableResourceId);
         if (logger == null) {
             MutableResourceId newMutableResourceId = new MutableResourceId(resourceId);
-            IIndex index = (IIndex) provider.getTransactionalResourceRepository().getTransactionalResource(resourceId);
+            IIndex index = (IIndex) txnSubsystem.getAsterixAppRuntimeContextProvider().getIndexLifecycleManager()
+                    .getIndex(resourceId);
             logger = new IndexLogger(resourceId, resourceType, index);
             loggers.put(newMutableResourceId, logger);
         }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java
index ca72204..7e4b5bb 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/IndexResourceManager.java
@@ -28,11 +28,11 @@
 
     public final byte resourceType;
 
-    private final TransactionSubsystem provider;
+    private final TransactionSubsystem txnSubsystem;
 
     public IndexResourceManager(byte resourceType, TransactionSubsystem provider) {
         this.resourceType = resourceType;
-        this.provider = provider;
+        this.txnSubsystem = provider;
     }
 
     public byte getResourceManagerId() {
@@ -46,7 +46,8 @@
         //TODO
         //replace TransactionResourceRepository with IndexLifeCycleManager
         // look up the repository to obtain the resource object
-        IIndex index = (IIndex) provider.getTransactionalResourceRepository().getTransactionalResource(resourceId);
+        IIndex index = (IIndex) txnSubsystem.getAsterixAppRuntimeContextProvider().getIndexLifecycleManager()
+                .getIndex(resourceId);
 
         /* field count */
         int fieldCount = logLocator.getBuffer().readInt(logLocator.getMemoryOffset() + offset);
@@ -112,7 +113,7 @@
         long resourceId = logRecordHelper.getResourceId(logLocator);
         int offset = logRecordHelper.getLogContentBeginPos(logLocator);
 
-        IIndex index = (IIndex) provider.getAsterixAppRuntimeContextProvider().getIndexLifecycleManager()
+        IIndex index = (IIndex) txnSubsystem.getAsterixAppRuntimeContextProvider().getIndexLifecycleManager()
                 .getIndex(resourceId);
 
         /* field count */
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/CheckpointObject.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/CheckpointObject.java
index b9dd59f..4d1b9a5 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/CheckpointObject.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/CheckpointObject.java
@@ -6,21 +6,15 @@
 
     private static final long serialVersionUID = 1L;
     
-    private final long checkpointLSN;
     private final long minMCTFirstLSN;
     private final int maxJobId;
     private final long timeStamp;
 
-    public CheckpointObject(long checkpointLSN, long minMCTFirstLSN, int maxJobId, long timeStamp) {
-        this.checkpointLSN = checkpointLSN;
+    public CheckpointObject(long minMCTFirstLSN, int maxJobId, long timeStamp) {
         this.minMCTFirstLSN = minMCTFirstLSN;
         this.maxJobId = maxJobId;
         this.timeStamp = timeStamp;
     }
-    
-    public long getCheckpointLSN() {
-        return checkpointLSN;
-    }
 
     public long getMinMCTFirstLSN() {
         return minMCTFirstLSN;
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
index 18e7be1..8bb1acf 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -38,7 +38,7 @@
 import edu.uci.ics.asterix.transaction.management.resource.LSMBTreeLocalResourceMetadata;
 import edu.uci.ics.asterix.transaction.management.resource.LSMInvertedIndexLocalResourceMetadata;
 import edu.uci.ics.asterix.transaction.management.resource.LSMRTreeLocalResourceMetadata;
-import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceRepository;
+import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceManagerRepository;
 import edu.uci.ics.asterix.transaction.management.service.logging.IBuffer;
 import edu.uci.ics.asterix.transaction.management.service.logging.ILogCursor;
 import edu.uci.ics.asterix.transaction.management.service.logging.ILogFilter;
@@ -84,13 +84,6 @@
 
     public RecoveryManager(TransactionSubsystem TransactionProvider) throws ACIDException {
         this.txnSubsystem = TransactionProvider;
-        /**********
-         * try {
-         * FileUtil.createFileIfNotExists(checkpoint_record_file);
-         * } catch (IOException ioe) {
-         * throw new ACIDException(" unable to create checkpoint record file " + checkpoint_record_file, ioe);
-         * }
-         ***********/
     }
 
     /**
@@ -114,10 +107,9 @@
             new ACIDException("Checkpoint file doesn't exist", e);
         }
 
-        //#. if checkpointLSN in the checkpoint file is equal to the lastLSN in the log file, 
+        //#. if minMCTFirstLSN is equal to -1,
         //   then return healthy state. Otherwise, return corrupted.
-        LogManager logMgr = (LogManager) txnSubsystem.getLogManager();
-        if (checkpointObject.getCheckpointLSN() == logMgr.getCurrentLsn().get()) {
+        if (checkpointObject.getMinMCTFirstLSN() == -1) {
             state = SystemState.HEALTHY;
             return state;
         } else {
@@ -137,7 +129,7 @@
         ILogManager logManager = txnSubsystem.getLogManager();
         ILogRecordHelper logRecordHelper = logManager.getLogRecordHelper();
         ITransactionManager txnManager = txnSubsystem.getTransactionManager();
-        TransactionalResourceRepository txnResourceRepository = txnSubsystem.getTransactionalResourceRepository();
+        TransactionalResourceManagerRepository txnResourceRepository = txnSubsystem.getTransactionalResourceRepository();
 
         //winnerTxnTable is used to add pairs, <committed TxnId, the most recent commit LSN of the TxnId>
         Map<TxnId, Long> winnerTxnTable = new HashMap<TxnId, Long>();
@@ -276,7 +268,7 @@
                                 txnSubsystem.getTransactionalResourceRepository().registerTransactionalResourceManager(
                                         resourceMgrId, resourceMgr);
                             }
-                            
+
                             //redo finally.
                             resourceMgr.redo(logRecordHelper, currentLogLocator);
                         }
@@ -307,9 +299,9 @@
         //#. create and store the checkpointObject into the new checkpoint file
         //TODO
         //put the correct minMCTFirstLSN by getting from Zach. :)
-        long minMCTFirstLSM = 0;
-        CheckpointObject checkpointObject = new CheckpointObject(logMgr.getCurrentLsn().get(), minMCTFirstLSM,
-                txnMgr.getMaxJobId(), System.currentTimeMillis());
+        long minMCTFirstLSM = -1;
+        CheckpointObject checkpointObject = new CheckpointObject(minMCTFirstLSM, txnMgr.getMaxJobId(),
+                System.currentTimeMillis());
 
         FileOutputStream fos = null;
         ObjectOutputStream oosToFos = null;
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionSubsystem.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionSubsystem.java
index ce9a280..1fc2765 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionSubsystem.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionSubsystem.java
@@ -15,7 +15,7 @@
 package edu.uci.ics.asterix.transaction.management.service.transaction;
 
 import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
-import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceRepository;
+import edu.uci.ics.asterix.transaction.management.resource.TransactionalResourceManagerRepository;
 import edu.uci.ics.asterix.transaction.management.service.locking.ILockManager;
 import edu.uci.ics.asterix.transaction.management.service.locking.LockManager;
 import edu.uci.ics.asterix.transaction.management.service.logging.ILogManager;
@@ -35,7 +35,7 @@
     private final ILockManager lockManager;
     private final ITransactionManager transactionManager;
     private final IRecoveryManager recoveryManager;
-    private final TransactionalResourceRepository resourceRepository;
+    private final TransactionalResourceManagerRepository resourceRepository;
     private final IndexLoggerRepository loggerRepository;
     private final IAsterixAppRuntimeContextProvider asterixAppRuntimeContextProvider;
 
@@ -47,7 +47,7 @@
         this.lockManager = new LockManager(this);
         this.recoveryManager = new RecoveryManager(this);
         this.loggerRepository = new IndexLoggerRepository(this);
-        this.resourceRepository = new TransactionalResourceRepository();
+        this.resourceRepository = new TransactionalResourceManagerRepository();
         this.asterixAppRuntimeContextProvider = asterixAppRuntimeContextProvider;
     }
 
@@ -67,7 +67,7 @@
         return recoveryManager;
     }
 
-    public TransactionalResourceRepository getTransactionalResourceRepository() {
+    public TransactionalResourceManagerRepository getTransactionalResourceRepository() {
         return resourceRepository;
     }