public override void TruncateFromProxyHandler(TruncateMessageReader request) { List <List <long> > cellIds = request.cellIds; List <Thread> threads = new List <Thread>(); foreach (List <long> cellId in cellIds) { if (Global.CloudStorage.GetServerIdByCellId(cellId[0]) == Global.MyServerId) //这一行第一列存储于本服务器 { RowMessage rm = new RowMessage(); rm.cellId = cellId; //每行开一个线程处理 Thread thread = new Thread(new ParameterizedThreadStart(TruncateThread)); threads.Add(thread); thread.Start(rm); } } foreach (Thread thr in threads) { thr.Join(); } //此时已经处理完结果 Global.CloudStorage.TruncateFromServerToDatabaseProxy(0, new TruncateResponceWriter(Global.MyServerId)); }
public override void TruncateFromClientHandler(TruncateMessageReader request) { idDict.Clear(); for (int i = 0; i < Global.ServerCount; i++) { //每个服务器挨个发送 TruncateMessageWriter tmw = new TruncateMessageWriter(request.cellIds); Global.CloudStorage.TruncateFromProxyToDatabaseServer(i, tmw); } sem.WaitOne(); //等待服务器全部返回信息 }