internal void ReceiveBlock(BlockInfo block) { try { //Trace.TraceInformation("ReceiveBlock: {0} received update notification for block {1}", RoleEnvironment.CurrentRoleInstance.Id, block); var cacheKey = MakeCacheKey(block.StoreName, block.Offset); #if BLOCKSTORECACHE _cache.Insert(block); #else _cache.Insert(cacheKey, block, CachePriority.High); #endif //Trace.TraceInformation("ReceiveBlock: Cache updated for block {0}", block); UpdateHighestOffset(block.StoreName, block.Offset); //Trace.TraceInformation("ReceiveBlock: Updated highest offset to {0}", block.Offset); // Update the list of blocks to be committed but with a delay to allow the originator time to do the update themselves. var updateTask = new Task(k => { Thread.Sleep(500); _commitList.Enqueue(block.Copy()); }, cacheKey); updateTask.Start(); } catch (Exception ex) { Trace.TraceError("ReceiveBlock {0} failed with exception {1}", block, ex); throw; } //Trace.TraceInformation("ReceiveBlock {0} completed.", block); }
private void NotifyBlockUpdate(BlockInfo block) { if (_disconnected) { return; } // Send notification to all other workers foreach (var workerInstance in RoleEnvironment.Roles[AzureConstants.StoreWorkerRoleName].Instances) { if (!workerInstance.Id.Equals(RoleEnvironment.CurrentRoleInstance.Id)) { try { var client = GetBlockServiceClient(workerInstance); client.UpdateBlock(block); //Trace.TraceInformation("NotifyBlockUpdate: {0} sent to {1}", block, workerInstance.Id); } catch (Exception ex) { Trace.TraceError("NotifyBlockUpdate {0} failed to notify instance {1}. Cause: {2}", block, workerInstance.Id, ex); } } } //Trace.WriteLine(String.Format("Enqueuing commit update for received block: {0}", /*cacheKey*/ block),"AzureBlockStore"); _commitList.Enqueue(block.Copy()); }
public void SetCell(CellValue newBlock, Cell cell) { if (newBlock.blockType != BlockShape.Empty) { BlockInfo info = new BlockInfo(); info.Copy(newBlock); blockMap[cell] = info; } else { blockMap.Remove(cell); } }