コード例 #1
0
        private static bool CheckDrivesAvailableSpace(MachineHealthContainer machineHealthContainer, string fabricDataRoot, string fabricLogRoot)
        {
            List <string> drives                       = new List <string>();
            string        candidateMachine             = machineHealthContainer.GetHealthyMachineNames().ElementAt(0);
            string        fabricPackageDestinationPath = Utility.GetDefaultPackageDestination(candidateMachine);
            string        fabricRootDrive              = Path.GetPathRoot(fabricPackageDestinationPath);

            drives.Add(fabricRootDrive);

            if (fabricDataRoot != null)
            {
                drives.Add(Path.GetPathRoot(fabricDataRoot));
            }

            if (fabricLogRoot != null)
            {
                drives.Add(Path.GetPathRoot(fabricLogRoot));
            }

            foreach (string drive in drives.Distinct())
            {
                Parallel.ForEach(
                    machineHealthContainer.GetHealthyMachineNames(),
                    (string machineName) =>
                {
                    string remoteRootDrive = Helpers.GetRemotePathIfNotLocalMachine(drive, machineName);
                    if (!StandaloneUtility.EnoughAvailableSpaceOnDrive(remoteRootDrive))
                    {
                        SFDeployerTrace.WriteError(StringResources.Error_BPANotEnoughSpaceOnDrive, drive, machineName);
                        machineHealthContainer.MarkMachineAsUnhealthy(machineName);
                    }
                });
            }

            return(machineHealthContainer.EnoughHealthyMachines());
        }