Ejemplo n.º 1
0
        private JobInfoObject CreateBackupJob(RecoveryOperation opContext)
        {
            JobInfoObject   infoObject = null;
            RecoveryJobBase dataJob    = null;
            RecoveryJobBase opLogJob   = null;

            #region BackupJob
            SubmitBackupOpParams bckpParam = (SubmitBackupOpParams)opContext.Parameter;

            // create handler object
            infoObject = new JobInfoObject(opContext.JobIdentifer, _context.LocalShardName, _context.LocalAddress.ip, _context.ClusterName,
                                           RecoveryJobType.DataBackup, bckpParam.PersistenceConfiguration.FilePath);

            foreach (string db in bckpParam.PersistenceConfiguration.DbCollectionMap.Keys)
            {
                //assuming one database is  sent
                dataJob = new DatabaseBackupJob(opContext.JobIdentifer, _context, db, bckpParam.PersistenceConfiguration.DbCollectionMap[db][db].ToList(), infoObject.RecoveryPersistenceManager, _context.ClusterName);
                dataJob.RegisterProgressHandler(this);
                infoObject.AddJob(dataJob);

                // set persistence configuration
                if (bckpParam.PersistenceConfiguration.FileName == null)
                {
                    bckpParam.PersistenceConfiguration.FileName = new List <string>();
                    bckpParam.PersistenceConfiguration.FileName.Add(db);//add name of all databases for shard level job
                }
                infoObject.RecoveryPersistenceManager.SetJobConfiguration(RecoveryJobType.DataBackup, bckpParam.PersistenceConfiguration, db, 1);
            }
            #endregion

            return(infoObject);
        }
Ejemplo n.º 2
0
        //M_TODO: must Specify DB name in case of shard job, so a separate job is created, for now this will run multiple times and override job if more
        //than one db is specified.
        private JobInfoObject CreateRestoreJob(RecoveryOperation opContext)
        {
            JobInfoObject   infoObject = null;
            RecoveryJobBase dataJob    = null;


            #region RestoreJob
            SubmitRestoreOpParams resParam = (SubmitRestoreOpParams)opContext.Parameter;

            foreach (string db in resParam.PersistenceConfiguration.DbCollectionMap.Keys)
            {
                // create handler object
                // Note: this is kept inside the loop with the assumption that a seperate info object is to be kept for each database in complete cluster job
                infoObject = new JobInfoObject(opContext.JobIdentifer, _context.LocalShardName, _context.LocalAddress.ip, _context.ClusterName,
                                               RecoveryJobType.DataRestore, resParam.PersistenceConfiguration.FilePath);

                string destination = resParam.PersistenceConfiguration.DbCollectionMap[db].Keys.First();

                // create DataJob
                dataJob = new DatabaseRestoreJob(opContext.JobIdentifer, _context, destination, resParam.PersistenceConfiguration.DbCollectionMap[db][destination].ToList <string>(), infoObject.RecoveryPersistenceManager, _context.ClusterName);
                dataJob.RegisterProgressHandler(this);
                infoObject.AddJob(dataJob);

                // set persistence configuration
                if (resParam.PersistenceConfiguration.FileName == null)
                {
                    resParam.PersistenceConfiguration.FileName = new List <string>();
                    resParam.PersistenceConfiguration.FileName.Add(db);//add name of all databases for shard level job
                }

                infoObject.RecoveryPersistenceManager.SetJobConfiguration(RecoveryJobType.DataRestore, resParam.PersistenceConfiguration, db, 1);
            }
            #endregion

            return(infoObject);
        }