public static void GenenateJobs()
        {
            int parallelThread = 10;

            for (int i = 0; i < NumberOfJobs / parallelThread; i++)
            {
                GridService[] gridServiceA = new GridService[parallelThread];
                for (int j = 0; j < parallelThread; j++)
                {
                    GridService gridService = GridAPI.createService(i + "");
                    Dictionary <String, String> parameters = new Dictionary <String, String>();
                    parameters.Add("param1", ((i * 10) + j) + "");
                    Console.WriteLine("Submiting Job");
                    Job job = gridService.Submit("Function1", parameters);
                    gridServiceA[j] = gridService;
                }
                stopWatch.Start();
                Task <ServiceData>[] taskArray =
                {
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[0].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[1].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[2].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[3].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[4].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[5].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[6].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[7].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[8].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[9].CollectNext(1000))
                };
                ServiceData[] serviceDataA = new ServiceData[taskArray.Length];
                for (int k = 0; k < taskArray.Length; k++)
                {
                    serviceDataA[k] = taskArray[k].Result;
                    for (int l = 0; l < serviceDataA[k].Data.Length; l++)
                    {
                        if (serviceDataA[k].Data[l] != null)
                        {
                            CalculateUtil.subreducer(aggResults, serviceDataA[k].Data[l].resultData);
                            totalCalcTime += serviceDataA[k].Data[l].Processingtime;
                        }
                    }
                    Console.WriteLine("From GenenateJobs using Task now Results found for k=" + k);
                }
            }
        }
Esempio n. 2
0
        public static void GenenateJobs()
        {
            int parallelThread = 10;

            for (int i = 0; i < NumberOfJobs / parallelThread; i++)
            {
                GridService[] gridServiceA = new GridService[parallelThread];
                for (int j = 0; j < parallelThread; j++)
                {
                    GridService gridService = GridAPI.createService(i + "");
                    Dictionary <String, String> parameters = new Dictionary <String, String>();
                    parameters.Add("param1", ((i * 10) + j) + "");
                    Job job = gridService.Submit("Function1", parameters);
                    gridServiceA[j] = gridService;
                }
                Task <ServiceData>[] taskArray =
                {
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[0].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[1].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[2].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[3].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[4].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[5].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[6].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[7].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[8].CollectNext(1000)),
                    Task <ServiceData> .Factory.StartNew(() => gridServiceA[9].CollectNext(1000))
                };
                ServiceData[] serviceDataA = new ServiceData[taskArray.Length];
                for (int k = 0; k < taskArray.Length; k++)
                {
                    serviceDataA[k] = taskArray[k].Result;
                    Console.Write("Result found for k" + k);
                }
            }
        }