/// <summary> /// Block report is the list of block ids contained in blockstorage /// </summary> public static DataNodeProto.BlockReportRequest CreateBlockReport() { Guid[] blockList = BlockStorage.GetBlocks(); List <DataNodeProto.UUID> blockIdList = new List <DataNodeProto.UUID>(); for (int i = 0; i < blockList.Length; i++) { blockIdList.Add(new DataNodeProto.UUID { Value = blockList[i].ToString() }); } DataNodeProto.BlockReportRequest BlockReportRequest = new DataNodeProto.BlockReportRequest { DataNode = new DataNodeProto.DataNode { IpAddress = Program.ipAddress }, BlockList = new DataNodeProto.BlockList { BlockId = { blockIdList } } }; return(BlockReportRequest); }
/// <summary> /// Sends a single block report /// </summary> /// <param name="client">Connection to NameNode</param> public static void SendSingleBlockReport(DataNodeProto.DataNodeProto.DataNodeProtoClient client) { try { DataNodeProto.BlockReportRequest blockReport = CreateBlockReport(); DataNodeProto.StatusResponse response = client.SendBlockReport(blockReport); } catch (RpcException e) { Console.WriteLine("Blockreport failed: " + e.Message); } }
// Server side handler of the SendBlockReportRequest RPC public override Task <DataNodeProto.StatusResponse> SendBlockReport(DataNodeProto.BlockReportRequest request, ServerCallContext context) { var blockListLength = request.BlockList.BlockId.Count(); Guid[] blockList = new Guid[blockListLength]; for (var i = 0; i < blockListLength; i++) { blockList[i] = Guid.Parse(request.BlockList.BlockId[i].Value); } return(Task.FromResult(DataNodeManager.Instance.ProcessBlockReport(blockList, request.DataNode.IpAddress))); }