changed the place where the checkpoint is executed

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1390 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index 5e0cb1b..f728abe 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -2,7 +2,6 @@
 
 import java.rmi.RemoteException;
 import java.rmi.server.UnicastRemoteObject;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -25,6 +24,7 @@
     private String nodeId;
     private boolean isMetadataNode = false;
     private boolean stopInitiated = false;
+    private SystemState systemState = SystemState.NEW_UNIVERSE;
 
     @Override
     public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
@@ -42,10 +42,12 @@
         
         //#. recover if the system is corrupted by checking system state.
         IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
-        if (recoveryMgr.getSystemState() == SystemState.CORRUPTED) {
+        systemState = recoveryMgr.getSystemState();
+        if (systemState == SystemState.CORRUPTED) {
             recoveryMgr.startRecovery(true);
+        } else if (systemState == SystemState.NEW_UNIVERSE) {
+            recoveryMgr.checkpoint(true);
         }
-        recoveryMgr.checkpoint(true);
     }
 
     @Override
@@ -83,6 +85,9 @@
             MetadataBootstrap.startDDLRecovery();
         }
         
+        IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+        recoveryMgr.checkpoint(true);
+        
         //TODO
         //reclaim storage for orphaned index artifacts in NCs.
     }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IRecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IRecoveryManager.java
index ed77629..38802a2 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IRecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/IRecoveryManager.java
@@ -28,6 +28,7 @@
 public interface IRecoveryManager {
 
     public enum SystemState {
+        NEW_UNIVERSE,
         RECOVERING,
         HEALTHY,
         CORRUPTED
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 1da84df..dee1df3 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
@@ -116,7 +116,7 @@
         } catch (FileNotFoundException e) {
             //This is initial bootstrap. 
             //Otherwise, the checkpoint file is deleted unfortunately. What we can do in this case?
-            state = SystemState.HEALTHY;
+            state = SystemState.NEW_UNIVERSE;
             return state;
         }