コード例 #1
0
 public void UpdateBlock(BlockInfo block)
 {
     if (block != null)
     {
         try
         {
             Trace.TraceInformation("Received update for block {0}", block);
             AzureBlockStore.Instance.ReceiveBlock(block);
         }
         catch (Exception ex)
         {
             Trace.TraceError("Error receiving block {0}. Cause: {1}", block, ex);
             // TODO: Should we drop some/all cached blocks for the same store to force a re-read from blobstore?
             /*
             AzureBlockStore.Instance.DropBlock(block.StoreName, block.Offset);
             if (block.Offset > AzureBlockStore.Instance.BlockSize)
             {
                 AzureBlockStore.Instance.DropBlock(block.StoreName,
                                                    block.Offset - AzureBlockStore.Instance.BlockSize);
             }
              */
             // Rethrow the exception as a service fault so that the sender knows this receiver has a problem.
             throw;
         }
     }
 }
コード例 #2
0
 public void Insert(BlockInfo block)
 {
     block.LastAccess = DateTime.UtcNow.Ticks;
     _cache[MakeKey(block)] = block;
     //Trace.WriteLine(String.Format("BlockStoreCache: Insert {0} with key {1}", block, MakeKey(block)));
     if (_cache.Count > _maxBlockCount && !_evictionStarted)
     {
         Task.Factory.StartNew(EvictOldBlocks);
     }
     if (block.Length == AzureBlockStore.AzureBlockSize)
     {
         WriteToDiskCache(block);
     }
 }
コード例 #3
0
 private static string MakeKey(BlockInfo block)
 {
     return MakeKey(block.StoreName, block.Offset);
 }
コード例 #4
0
 private void WriteToDiskCache(BlockInfo block)
 {
     // Start a background thread to write the block to the disk
     Task.Factory.StartNew(
         () =>
             {
                 try
                 {
                     _diskCache.PutData(MakeKey(block), block.Data);
                 }
                 catch (Exception e)
                 {
                     Trace.TraceWarning("Error writing block to disk cache: {0}", e);
                 }
             });
 }
コード例 #5
0
 private static string MakeCacheFileName(BlockInfo block)
 {
     return MakeCacheFileName(MakeKey(block));
 }