当前位置: 首页>>代码示例>>C#>>正文


C# IWorker.SetUpAsSecondaryServer方法代码示例

本文整理汇总了C#中IWorker.SetUpAsSecondaryServer方法的典型用法代码示例。如果您正苦于以下问题:C# IWorker.SetUpAsSecondaryServer方法的具体用法?C# IWorker.SetUpAsSecondaryServer怎么用?C# IWorker.SetUpAsSecondaryServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWorker的用法示例。


在下文中一共展示了IWorker.SetUpAsSecondaryServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartPrimaryJobTrackerProcess

        private void StartPrimaryJobTrackerProcess(string clientUrl, long fileSize, long numSplits, string mapperName, byte[] mapperCode)
        {
            currentJobTrackerUrl = this.myURL;
            serverRole = ServerRole.JOB_TRACKER;
            status = ExecutionState.WORKING;
            isPrimary = true;
            jtInformation = new JobTrackerInformation(this, numSplits);
            this.clientURL = clientUrl;
            this.fileSize = fileSize;
            client = (IClient)Activator.GetObject(typeof(IClient), clientURL);
            this.mapperName = mapperName;
            this.mapperCode = mapperCode;
            Thread trackWorkersThread = new Thread(() =>
            {
                while (!jtInformation.DidFinishJob() && isPrimary && serverRole == ServerRole.JOB_TRACKER)
                {
                    /* wait until if I am unfrozen and revert to Worker if needed */
                    if (WaitForUnfreezeAndCheckChanges())
                        break;
                    /* --------------------------- */

                    Logger.LogInfo("[CHECKING SLOW WORKERS]");
                    SplitInfo slowSplit = jtInformation.FindSlowSplit();
                    if (slowSplit != null)
                    {
                        //Logger.LogWarn("There is a slow split - " + slowSplit.splitId);
                        IWorker freeWorker = jtInformation.GetFirstFreeWorker();
                        if (freeWorker != null)
                        {
                            Logger.LogWarn("[SLOWWWWWWW SPLIT] RESENDING " + slowSplit.remainingSplits);
                            ResendSplitToNextWorker(freeWorker, slowSplit.fileSize, slowSplit.totalSplits, slowSplit.remainingSplits);
                        }
                    }
                    Thread.Sleep(4000);
                }

                serverRole = ServerRole.NONE;
                status = ExecutionState.WAITING;
            });
            trackWorkersThread.Start();

            Thread ConfigureSecondaryServerThread = new Thread(() =>
            {
                //wait for an available backUrl, then pings it then sets up as primary Server
                while (isPrimary && serverRole == ServerRole.JOB_TRACKER && !jtInformation.DidFinishJob())
                {
                    if (backURL == myURL)
                    {
                        continue;
                    }

                    //Logger.LogInfo("Waiting for an available url to be the secondary JT");
                    secondaryJT = (IWorker)Activator.GetObject(typeof(IWorker), backURL);

                    try
                    {
                        secondaryJT.PingJT();
                        backupSecondaryServerIfFailsUrl = secondaryJT.SetUpAsSecondaryServer(this.clientURL, this.myURL, fileSize, numSplits, mapperName, mapperCode);

                        backupSecondaryServerIfFails = (IWorker)Activator.GetObject(typeof(IWorker), backupSecondaryServerIfFailsUrl);

                        Logger.LogInfo("Success setting setup backupserver");
                        break;
                    }
                    catch(Exception)
                    {
                        Logger.LogInfo("There is still no backUrl available to become backup server");
                    }

                    Thread.Sleep(1000);
                }

            });
            ConfigureSecondaryServerThread.Start();

            if (!primaryDidStartedJob && !firstRequest)
            {
                primaryDidStartedJob = true;
                ReceiveWork(clientUrl, fileSize, numSplits, mapperName, mapperCode);
            }

            firstRequest = false;
        }
开发者ID:bphenriques,项目名称:PADI-2015,代码行数:83,代码来源:NodePartialJtMethods.cs


注:本文中的IWorker.SetUpAsSecondaryServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。