コード例 #1
0
        /// <summary>
        /// Snapshots the data drive of the given instance number.
        /// </summary>
        /// <param name="instanceNum">The number of the instance to snapshot.</param>
        /// <param name="credential">The Azure Storage credential string to use</param>
        /// <param name="replicaSetName">The name of the MongoDB replica set</param>
        public static Uri MakeSnapshot(int instanceNum, string credential, string replicaSetName)
        {
            var client = CloudStorageAccount.Parse(credential).CreateCloudBlobClient();

            // Load the blob...
            var container = client.GetContainerReference(ConnectionUtilities.GetDataContainerName(replicaSetName));
            var blob      = container.GetPageBlobReference(String.Format(Constants.MongoDataBlobName, instanceNum));

            // Snapshot it.
            var snapshot = blob.CreateSnapshot();

            return(GetSnapshotUri(snapshot));
        }
コード例 #2
0
        /// <summary>
        /// Returns all the snapshots available.
        /// </summary>
        /// <param name="credential">The Azure Storage credential string to use</param>
        /// <param name="replicaSetName">The name of the MongoDB replica set</param>
        public static List <CloudBlob> GetSnapshots(string credential, string replicaSetName)
        {
            var client = CloudStorageAccount.Parse(credential).CreateCloudBlobClient();

            // Load the container.
            var container = client.GetContainerReference(ConnectionUtilities.GetDataContainerName(replicaSetName));

            // Collect all the snapshots!
            return(container.ListBlobs(new BlobRequestOptions()
            {
                BlobListingDetails = BlobListingDetails.Snapshots,
                UseFlatBlobListing = true
            }).Select(item => ((CloudBlob)item)).Where(item => item.SnapshotTime.HasValue).ToList());
        }
コード例 #3
0
        private string GetMongoDataDirectory()
        {
            DiagnosticsHelper.TraceInformation("Getting db path");
            var dataBlobName  = string.Format(Constants.MongoDataBlobName, instanceId);
            var containerName = ConnectionUtilities.GetDataContainerName(replicaSetName);

            mongodDataDriveLetter = Utilities.GetMountedPathFromBlob(
                Settings.LocalCacheDirSetting,
                Constants.MongoDataCredentialSetting,
                containerName,
                dataBlobName,
                Settings.MaxDBDriveSizeInMB,
                out mongoDataDrive);
            DiagnosticsHelper.TraceInformation("Obtained data drive as {0}", mongodDataDriveLetter);
            var dir = Directory.CreateDirectory(Path.Combine(mongodDataDriveLetter, @"data"));

            DiagnosticsHelper.TraceInformation("Data directory is {0}", dir.FullName);
            return(dir.FullName);
        }