/*Check point entry */
        public void DoCheckPointAllUsers(CheckPointObject filesystem)
        {
            logger.Debug ("Do Check point method called for filesystem for timestamp : " + filesystem.lastcheckpoint);
            CheckPointObject oldcheckpointobject = RestoreFileSystem (true); //load the old file in memory to merege

            //logger.Debug ("POOP1  : " + oldcheckpointobject.userfilesystemlist[0].metadata.totalFileSystemSizeBytes);
            //logger.Debug ("POOP2  : " + filesystem.userfilesystemlist[0].metadata.totalFileSystemSizeBytes);
            DateTime newCheckPointTime = filesystem.lastcheckpoint;
            filesystem = mergeCheckPointObjects (filesystem, oldcheckpointobject);
            filesystem.lastcheckpoint = newCheckPointTime;
            //logger.Debug (filesystem);

            try {
                string path = GenerateCheckpointPath (filesystem.lastcheckpoint);
                logger.Debug ("Creating checkpointing path :" + path);
                Directory.CreateDirectory (path);
                string lastcheckpointfilepath = CheckpointLogic.pathprefix + CheckpointLogic.lastcheckpointfilename;
                foreach( UserFileSystem userfs in filesystem.userfilesystemlist){
                    DoCheckPointForUser( userfs.metadata.clientId, path, userfs);
                }

                //Now update the last check point file so that we can restore this checkpoint
                logger.Debug ("Writing to last checkpoint file at path : " + lastcheckpointfilepath);
                System.IO.File.WriteAllText(lastcheckpointfilepath,
                          DateUtils.getStringfromDateTime(filesystem.lastcheckpoint) + "\n" + path);

            }catch ( Exception e){
                    logger.Debug ("Exception :" + e);
                throw e;
            }
        }
Beispiel #2
0
        public CheckPointObject RestoreFileSystem(bool restoreFileContent)
        {
            logger.Debug("Restoring file system with restore file content as : " + restoreFileContent);
            CheckPointObject checkObject            = new CheckPointObject();
            string           lastcheckpointfilepath = pathprefix + lastcheckpointfilename;

            try {
                List <string> lastcheckpointfilecontent = FileUtils.ReadLinesFromFile(lastcheckpointfilepath);
                logger.Debug("Last check point time stamp read :" + lastcheckpointfilecontent [0].Trim());
                DateTime lastcheckpointtime = DateUtils.getDatefromString(lastcheckpointfilecontent [0].Trim());

                logger.Debug("Read last checkpoint time as :" + lastcheckpointtime);
                checkObject.lastcheckpoint = lastcheckpointtime;
                if (lastcheckpointfilecontent.Count < 2)
                {
                    throw new DiskuserMetaDataCorrupt("Something wrong with the last check point file path, check!!");
                }

                string latestcheckpointfolderpath = lastcheckpointfilecontent [1];
                logger.Debug("Last check point path read as :" + latestcheckpointfolderpath);
                latestcheckpointfolderpath = latestcheckpointfolderpath.Trim();                  //remove any leading or trailing whitespaces
                foreach (string userfolder in Directory.EnumerateDirectories(latestcheckpointfolderpath))
                {
                    checkObject.userfilesystemlist.Add(RestoreUserFileSystem(userfolder, restoreFileContent));
                }
                logger.Debug("Returning the check point object as :" + checkObject.userfilesystemlist.Count);
            } catch (Exception e) {
                logger.Warn("Exception occured while restoring the file system : " + e);
            }
            return(checkObject);
        }
Beispiel #3
0
        /*Check point entry */
        public void DoCheckPointAllUsers(CheckPointObject filesystem)
        {
            logger.Debug("Do Check point method called for filesystem for timestamp : " + filesystem.lastcheckpoint);
            CheckPointObject oldcheckpointobject = RestoreFileSystem(true);              //load the old file in memory to merege

            //logger.Debug ("POOP1  : " + oldcheckpointobject.userfilesystemlist[0].metadata.totalFileSystemSizeBytes);
            //logger.Debug ("POOP2  : " + filesystem.userfilesystemlist[0].metadata.totalFileSystemSizeBytes);
            DateTime newCheckPointTime = filesystem.lastcheckpoint;

            filesystem = mergeCheckPointObjects(filesystem, oldcheckpointobject);
            filesystem.lastcheckpoint = newCheckPointTime;
            //logger.Debug (filesystem);

            try {
                string path = GenerateCheckpointPath(filesystem.lastcheckpoint);
                logger.Debug("Creating checkpointing path :" + path);
                Directory.CreateDirectory(path);
                string lastcheckpointfilepath = CheckpointLogic.pathprefix + CheckpointLogic.lastcheckpointfilename;
                foreach (UserFileSystem userfs in filesystem.userfilesystemlist)
                {
                    DoCheckPointForUser(userfs.metadata.clientId, path, userfs);
                }

                //Now update the last check point file so that we can restore this checkpoint
                logger.Debug("Writing to last checkpoint file at path : " + lastcheckpointfilepath);
                System.IO.File.WriteAllText(lastcheckpointfilepath,
                                            DateUtils.getStringfromDateTime(filesystem.lastcheckpoint) + "\n" + path);
            }catch (Exception e) {
                logger.Debug("Exception :" + e);
                throw e;
            }
        }
Beispiel #4
0
        /*Check point entry */
        public void DoCheckPoint(CheckPointObject filesystem)
        {
            logger.Debug("Check point method called for filesystem");
            try{
                string path = GenerateCheckpointPath(filesystem.lastcheckpoint);
                logger.Debug("Creating checkpointing path :" + path);
                Directory.CreateDirectory(path);
                string lastcheckpointfilepath = this.pathprefix + this.lastcheckpointfilename;
                foreach (UserFileSystem userfs in filesystem.userfilesystemlist)
                {
                    DoCheckPointForUser(userfs.metadata.clientId, path, userfs);
                }

                //Now update the last check point file so that we can restore this checkpoint
                logger.Debug("Writing to last checkpoint file at path : " + lastcheckpointfilepath);
                System.IO.File.WriteAllText(lastcheckpointfilepath,
                                            DateUtils.getStringfromDateTime(filesystem.lastcheckpoint) + "\n" + path);
            }catch (Exception e) {
                logger.Debug("Exception :" + e);
                throw e;
            }
        }
Beispiel #5
0
        //Merge the check point objects
        private CheckPointObject mergeCheckPointObjects(CheckPointObject newimage, CheckPointObject oldimage)
        {
            logger.Debug("Merge check point objects");
            CheckPointObject retObject = new CheckPointObject();              //ret object

            foreach (UserFileSystem newfs in newimage.userfilesystemlist)
            {
                bool found = false;
                foreach (UserFileSystem oldfs in oldimage.userfilesystemlist)
                {
                    if (oldfs.metadata.clientId.Equals(newfs.metadata.clientId))                        //match based on user id
                    {
                        found = true;
                        retObject.userfilesystemlist.Add(mergeUserFileSystems(newfs, oldfs));
                    }
                }
                if (!found)
                {
                    retObject.userfilesystemlist.Add(newfs);
                }
            }
            return(retObject);
        }
Beispiel #6
0
        }                                   //default contructor

        public CheckPointObject RestoreFileSystem()
        {
            logger.Debug("Restoring file system");
            CheckPointObject checkObject            = new CheckPointObject();
            string           lastcheckpointfilepath = pathprefix + lastcheckpointfilename;

            List <string> lastcheckpointfilecontent = FileUtils.ReadLinesFromFile(lastcheckpointfilepath);

            logger.Debug("Last check point time stamp read :" + lastcheckpointfilecontent[0].Trim());
            DateTime lastcheckpointtime = DateUtils.getDatefromString(lastcheckpointfilecontent[0].Trim());

            checkObject.lastcheckpoint = lastcheckpointtime;
            logger.Debug("Poop : " + checkObject.lastcheckpoint);
            string latestcheckpointfolderpath = lastcheckpointfilecontent [1];

            logger.Debug("Last check point path read as :" + latestcheckpointfolderpath);
            latestcheckpointfolderpath = latestcheckpointfolderpath.Trim();              //remove any leading or trailing whitespaces
            foreach (string userfolder in Directory.EnumerateDirectories(latestcheckpointfolderpath))
            {
                checkObject.userfilesystemlist.Add(RestoreUserFileSystem(userfolder));
            }

            return(checkObject);
        }
        //Merge the check point objects
        private CheckPointObject mergeCheckPointObjects(CheckPointObject newimage, CheckPointObject oldimage)
        {
            logger.Debug ("Merge check point objects");
            CheckPointObject retObject = new CheckPointObject (); //ret object

            foreach (UserFileSystem newfs in newimage.userfilesystemlist) {
                bool found = false;
                foreach (UserFileSystem oldfs in oldimage.userfilesystemlist) {
                    if (oldfs.metadata.clientId.Equals (newfs.metadata.clientId)) { //match based on user id
                        found = true;
                        retObject.userfilesystemlist.Add (mergeUserFileSystems (newfs, oldfs));
                    }
                }
                if (! found) {
                    retObject.userfilesystemlist.Add (newfs);
                }
            }
            return retObject;
        }
        public CheckPointObject RestoreFileSystem(bool restoreFileContent)
        {
            logger.Debug ("Restoring file system with restore file content as : " + restoreFileContent);
            CheckPointObject checkObject = new CheckPointObject ();
            string lastcheckpointfilepath = pathprefix + lastcheckpointfilename;

            try {
                List<string> lastcheckpointfilecontent = FileUtils.ReadLinesFromFile (lastcheckpointfilepath);
                logger.Debug ("Last check point time stamp read :" + lastcheckpointfilecontent [0].Trim ());
                DateTime lastcheckpointtime = DateUtils.getDatefromString (lastcheckpointfilecontent [0].Trim ());

                logger.Debug ("Read last checkpoint time as :" + lastcheckpointtime);
                checkObject.lastcheckpoint = lastcheckpointtime;
                if (lastcheckpointfilecontent.Count < 2)
                    throw new DiskuserMetaDataCorrupt ("Something wrong with the last check point file path, check!!");

                string latestcheckpointfolderpath = lastcheckpointfilecontent [1];
                logger.Debug ("Last check point path read as :" + latestcheckpointfolderpath);
                latestcheckpointfolderpath = latestcheckpointfolderpath.Trim (); //remove any leading or trailing whitespaces
                foreach (string userfolder in Directory.EnumerateDirectories(latestcheckpointfolderpath)) {
                    checkObject.userfilesystemlist.Add (RestoreUserFileSystem (userfolder, restoreFileContent));
                }
                logger.Debug ("Returning the check point object as :" + checkObject.userfilesystemlist.Count);

            } catch (Exception e) {
                logger.Warn ("Exception occured while restoring the file system : " + e);
            }
            return checkObject;
        }