WEB开发网
开发学院服务器云计算 保护模拟运算表并使其不受应用错误的影响 阅读

保护模拟运算表并使其不受应用错误的影响

 2010-06-21 00:00:00 来源:WEB开发网   
核心提示: BackupTables是登录备份进程的方法,客户可以为每个表格提供一个TableKeyInfo,保护模拟运算表并使其不受应用错误的影响(2),例如,如果拆分密钥是GUID,此示例按顺序完成上述操作,以加快从Blob中恢复实体数据的进程,下面是如何援引BackupTables方法: CloudT

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;
    }
}

上一页  1 2 3 4 5 6 7  下一页

Tags:保护 模拟 运算

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接