天下网吧 >> 网吧天地 >> 网吧技术 >> 网吧软件 >> 正文

如何在Windows Azure存储中备份模拟运算表

2010-5-18不详佚名

         BackupTables是登录备份进程的方法。客户可以为每个表格提供一个TableKeyInfo。例如,如果拆分密钥是GUID,下面是如何援引BackupTables方法: CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint.AbsoluteUri, account.Credentials); CloudBlobClient blobClient = new CloudBlobClient(account.BlobEndpoint.AbsoluteUri, account.Credentials);   // The more keys listed here, the better for scale string[] rangeQueries = new string[] { "3", "8", "a", "f" }; string[] tableNames = new string[] { "Customers", "Orders" };   List<TableKeysInfo> keyInfo = new List<TableKeysInfo>(); foreach(string tableName in tableNames) {      keyInfo.Add( new TableKeysInfo(tableName, rangeQueries)); }   BackupTables(tableClient, blobClient, keyInfo);

      BackupTables现在已经完成每个表格以及表格中每个排列范围的迭代,它援引了BackupTableRange,而BackupTableRange负责将指定排列范围的结果集保存到Blob中。简单地说,此示例按顺序完成上述操作,以加快从Blob中恢复实体数据的进程,就需要将下面的内容并入操作之中。 /// <summary> /// Backup each table to blobs. Each table will be stored under a container with same name as the table. /// </summary> /// <param name="tableClient"></param> /// <param name="blobClient"></param> /// <param name="tablesToBackup"> /// The tablesToBackup will contain the table name to a list of keys that will be used to partition the query /// </param> public static void BackupTables(CloudTableClient tableClient,                    CloudBlobClient blobClient, List<TableKeysInfo> tablesToBackup) {     if (tableClient == null)     {         throw new ArgumentNullException("tableClient");     }       try     {         // we will use this id as the folder name. The blobs will be stored under:         //  <lower cased table name>/<backupid>/         string backupId = DateTime.UtcNow.ToString("yy-MM-dd-HH-mm-ss");           // list each range in each table and backup up each range         foreach (TableKeysInfo tableKeysInfo in tablesToBackup)         {             CloudBlobContainer container = blobClient.GetContainerReference(tableKeysInfo.TableName.ToLower());             container.CreateIfNotExist();               foreach (PartitionKeyRange range in tableKeysInfo.KeyRangeList)             {                 BackupTableRange(tableClient, container, tableKeysInfo.TableName, range, backupId);             }         }     }     catch (Exception e)     {         // TODO: log exception for debugging purpose and then rethrow           throw;     } }

9 7 3 1 2 3 4 5 6 4 8 :

本文来源:不详 作者:佚名

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。文章是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。 Email:support@txwb.com,系统开号,技术支持,服务联系微信:_WX_1_本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧·网吧天下
  • 本周热门
  • 本月热门
  • 阅读排行