Ejemplo n.º 1
0
 static void DistributedLoad(int server, DistributedLoad dload)
 {
     using (var request = new DistributedLoadWriter(dload.serverID, dload.fromServerID, dload.num_elements, dload.cellid1, dload.cellid2, dload.weight, dload.single_element, false))
     {
         Global.CloudStorage.DistributedLoadMessageToBenchmarkServer(server, request);
     }
 }
Ejemplo n.º 2
0
        public void SenderThread(object nthread)
        {
            int             senderThreadId = (int)nthread;
            Load            new_load;
            DistributedLoad distributedLoad = new DistributedLoad();

            distributedLoad.cellid1        = new long[4194304];
            distributedLoad.cellid2        = new long[4194304];
            distributedLoad.weight         = new float[4194304];
            distributedLoad.single_element = new bool[4194304];
            int index = 0;

            while (finished_readers < num_threads || load_sender_queue[senderThreadId].Count > 0)
            {
                try{
                    if (load_sender_queue[senderThreadId].TryDequeue(out new_load))
                    {
                        distributedLoad.cellid1[index]        = new_load.cellid1;
                        distributedLoad.cellid2[index]        = new_load.cellid2;
                        distributedLoad.weight[index]         = new_load.weight;
                        distributedLoad.single_element[index] = new_load.single_element;
                        Interlocked.Increment(ref all_threads_sent_edges);
                        index++;
                        if (index >= 4194000)
                        {
                            //Console.WriteLine("Send Load to Server " + senderThreadId);
                            using (var request = new DistributedLoadWriter(senderThreadId, this_server_id, index, distributedLoad.cellid1, distributedLoad.cellid2, distributedLoad.weight, distributedLoad.single_element, false))
                            {
                                Global.CloudStorage.DistributedLoadMessageToBenchmarkServer(senderThreadId, request);
                            }
                            distributedLoad                = new DistributedLoad();
                            distributedLoad.cellid1        = new long[4194304];
                            distributedLoad.cellid2        = new long[4194304];
                            distributedLoad.weight         = new float[4194304];
                            distributedLoad.single_element = new bool[4194304];
                            index = 0;
                        }
                    }
                    else
                    {
                        Thread.Sleep(50);
                    }
                } catch (Exception ex) {
                    Console.Error.WriteLine(ex.Message + " INDEX:" + index);
                    Console.Error.WriteLine(ex.StackTrace.ToString());
                }
            }
            try{
                // Last Send
                Console.WriteLine("Send LAST Load to Server " + senderThreadId + " " + index);
                using (var request = new DistributedLoadWriter(senderThreadId, this_server_id, index, distributedLoad.cellid1, distributedLoad.cellid2, distributedLoad.weight, distributedLoad.single_element, true))
                {
                    Global.CloudStorage.DistributedLoadMessageToBenchmarkServer(senderThreadId, request);
                }
            } catch (Exception ex) {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace.ToString());
            }
        }