本文整理汇总了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;
}