Ejemplo n.º 1
0
        private static RecoveryOperationStatus ValidateShardFolder(string path, bool checkDif)
        {
            RecoveryOperationStatus state = new RecoveryOperationStatus(RecoveryStatus.Failure);
            string shardPath = Path.Combine(path);

            if (!checkDif)
            {
                if (!Directory.Exists(shardPath))
                {
                    state.Status  = RecoveryStatus.Failure;
                    state.Message = "Provided path '" + path + "' for restore does not exist";
                    return(state);
                }
            }

            state.Status = RecoveryStatus.Success;
            return(state);
        }
Ejemplo n.º 2
0
        private static RecoveryOperationStatus ValidateConfigFolder(string path, bool checkDif)
        {
            RecoveryOperationStatus state = new RecoveryOperationStatus(RecoveryStatus.Failure);
            string configPath             = Path.Combine(path, CONFIG_FOLDER);

            if (!checkDif)
            {
                if (!Directory.Exists(configPath))
                {
                    state.Message = "Path for config server restore not provided";
                    return(state);
                }
            }

            state.Status = RecoveryStatus.Success;


            return(state);
        }
Ejemplo n.º 3
0
        private static RecoveryOperationStatus RemoteValidateShardFolder(string path, bool checkDif, List <string> shardNameList)
        {
            RecoveryOperationStatus state = new RecoveryOperationStatus(RecoveryStatus.Failure);

            foreach (string shardName in shardNameList)
            {
                if (!string.IsNullOrEmpty(shardName))
                {
                    if (!checkDif)
                    {
                        if (!Directory.Exists(path))
                        {
                            state.Message = "Path for '" + shardName + "' restore not provided";
                            return(state);
                        }
                    }
                }
            }
            state.Status = RecoveryStatus.Success;
            return(state);
        }
Ejemplo n.º 4
0
        public static RecoveryOperationStatus ValidateFolderStructure(string path, RecoveryJobType jobType, bool configCheck, List <string> shardNameList)
        {
            RecoveryOperationStatus state = new RecoveryOperationStatus(RecoveryStatus.Success);

            try
            {
                // based on folder type  shared or local
                // 1. check if folder accessible
                // 2. check if provided folders comply with the requirements
                bool networkPath = PathIsNetworkPath(path);

                if (networkPath)
                {
                    if (configCheck)
                    {
                        if (!Directory.Exists(path))
                        {
                            state.Status  = RecoveryStatus.Failure;
                            state.Message = "Provided path'" + path + "' is invalid or access is denied";
                            return(state);
                        }
                    }

                    switch (jobType)
                    {
                    case RecoveryJobType.ConfigRestore:
                        state = ValidateConfigFolder(path, false);
                        if (state.Status == RecoveryStatus.Failure)
                        {
                            return(state);
                        }
                        break;

                    case RecoveryJobType.Restore:
                        state = ValidateConfigFolder(path, false);
                        if (state.Status == RecoveryStatus.Failure)
                        {
                            return(state);
                        }
                        state = RemoteValidateShardFolder(path, false, shardNameList);
                        break;

                    case RecoveryJobType.DataRestore:
                        state = RemoteValidateShardFolder(path, false, shardNameList);
                        if (state.Status == RecoveryStatus.Failure)
                        {
                            return(state);
                        }
                        //check for file paths of all shards
                        break;

                    case RecoveryJobType.Export:
                        if (!Directory.Exists(path))
                        {
                            state.Message = "Path provided is invalid or access is denied";
                        }
                        break;

                    case RecoveryJobType.Import:
                        if (!File.Exists(path))
                        {
                            state.Message = "Path provided is invalid or access is denied";
                        }
                        break;
                    }
                    if (state.Status == RecoveryStatus.Failure)
                    {
                        return(state);
                    }
                }
                else
                {
                    if (configCheck)
                    {
                        if (Directory.Exists(path))
                        {
                            switch (jobType)
                            {
                            case RecoveryJobType.ConfigRestore:
                            case RecoveryJobType.Restore:
                                state = ValidateConfigFolder(path, false);
                                if (state.Status == RecoveryStatus.Failure)
                                {
                                    return(state);
                                }
                                break;
                            }
                        }
                        else
                        {
                            state.Message = "Path provided is invalid or access is denied";
                        }
                    }
                    else
                    {
                        switch (jobType)
                        {
                        case RecoveryJobType.DataRestore:
                            state = ValidateShardFolder(path, false);
                            if (state.Status == RecoveryStatus.Failure)
                            {
                                return(state);
                            }
                            break;

                        case RecoveryJobType.Export:
                            if (!Directory.Exists(path))
                            {
                                state.Message = "Path provided is invalid or access is denied";
                                return(state);
                            }
                            break;

                        case RecoveryJobType.Import:
                            if (!File.Exists(path))
                            {
                                state.Message = "Path provided is invalid or access is denied";
                                return(state);
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                state.Message = exp.ToString();
            }
            return(state);
        }