private void ResendSplitToNextWorker(IWorker worker, long fileSize, long totalSplits, long remainingSplits) { FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(worker.FetchWorker); Thread liveCheck = new Thread(this.liveCheck); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, myURL, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, false, null, null); liveCheck.Start(RemAr); }
public void liveCheck(object ar) { IAsyncResult iar = (IAsyncResult)ar; Thread.Sleep(TIMEOUT); if (!iar.IsCompleted) { IWorker worker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); try { bool alive = worker.IsAlive(); } catch (Exception ex) { Logger.LogErr("exception: " + ex.ToString()); Logger.LogErr(" ---- NODE DOWN ALERT ---- "); nodeDown(); PrintUpdateNetwork(); worker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(worker.FetchWorker); if (backupStatus == ExecutionState.WORKING) { IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, true, null, null); } else { if (remainingSplits > 1) { IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits - 1, myURL, true, null, null); } } } } }
public void ReceiveWork(string clientURL, long fileSize, long splits, string mapperName, byte[] mapperCode) { try { Logger.LogInfo("Received: " + clientURL + " with " + splits + " splits fileSize =" + fileSize); if (!didStartedPrimaryProcess) { StartPrimaryJobTrackerProcess(clientURL, fileSize, splits, mapperName, mapperCode); didStartedPrimaryProcess = true; } /* wait until if I am unfrozen and revert to Worker if needed */ Logger.LogWarn("Testing in freeze state"); WaitForUnfreezeAndCheckChanges(); /* --------------------------- */ IWorker nextWorker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); if (splits > fileSize) { splits = fileSize; } long splitSize = fileSize / splits; FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(nextWorker.FetchWorker); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, myURL, mapperName, mapperCode, fileSize, splits, splits, myURL, true, null, null); if (secondaryJT == null) { Logger.LogErr("Job tracker backup hasn't been configured yet"); secondaryJT.PrimaryStartedJob(); } return; } catch (RemotingException e) { Logger.LogErr("Remoting Exception: " + e.Message); } }
public void liveCheck(object ar) { IAsyncResult iar = (IAsyncResult)ar; Thread.Sleep(TIMEOUT); if (!iar.IsCompleted) { IWorker worker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); try { bool alive = worker.IsAlive(); } catch (Exception ex) { Logger.LogErr("exception: " + ex.ToString()); Logger.LogErr(" ---- NODE DOWN ALERT ---- "); nodeDown(); PrintUpdateNetwork(); worker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(worker.FetchWorker); if (backupStatus == ExecutionState.WORKING) { IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, true, null, null); } else { if (remainingSplits > 1) { IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits - 1, myURL, true, null, null); } } } } }
public bool FetchWorker(string clientURL, string jobTrackerURL, string mapperName, byte[] mapperCode, long fileSize, long totalSplits, long remainingSplits, string backURL, bool propagateRemainingSplits) { try { /* wait until if I am unfrozen */ WaitForUnfreeze(); /* --------------------------- */ //dead node revived!!! nooooooooo ! if (!backURL.Equals(this.backURL)) { Logger.LogInfo("Receiving work from the Dead. Invoking Node Registration"); //do stuff to recover that node back to the network IWorker revivedWorker = (IWorker)Activator.GetObject(typeof(IWorker), backURL); RecoverDeadNodeAsyncDel deadDel = new RecoverDeadNodeAsyncDel(revivedWorker.Register); IAsyncResult deadResponse = deadDel.BeginInvoke(currentJobTrackerUrl, null, null); return true; } currentJobTrackerUrl = jobTrackerURL; currentJobTracker = (IWorker)Activator.GetObject(typeof(IWorker), currentJobTrackerUrl); backupWorkData(status, clientURL, jobTrackerURL, mapperName, mapperCode, fileSize, totalSplits, remainingSplits); IWorker worker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(worker.FetchWorker); Thread liveCheck = new Thread(this.liveCheck); if (serverRole == ServerRole.JOB_TRACKER) { IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, true, null, null); liveCheck.Start(RemAr); } else { if (!didRegisted) { RegisterAtJobTracker(); didRegisted = true; } if (status == ExecutionState.WORKING && propagateRemainingSplits) { Logger.LogInfo("[JT FORWARD] Forwarded work from JobTracker: " + currentJobTrackerUrl + " remainingSplits: " + remainingSplits); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, true, null, null); liveCheck.Start(RemAr); } else { Logger.LogInfo("[RECEIVED SPLIT] Received Work from JobTracker: " + currentJobTrackerUrl + " remainingSplits: " + remainingSplits); LogStartSplit(id, fileSize, totalSplits, remainingSplits); serverRole = ServerRole.WORKER; status = ExecutionState.WORKING; this.clientURL = clientURL; client = (IClient)Activator.GetObject(typeof(IClient), clientURL); if (remainingSplits > 1 && propagateRemainingSplits) { Logger.LogInfo("[WORKER FORWARD NEXT SPLIT]"); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits - 1, myURL, true, null, null); liveCheck.Start(RemAr); } long startSplit = (remainingSplits - 1) * (fileSize / totalSplits); long endSplit; if (remainingSplits == totalSplits) { endSplit = fileSize; } else { endSplit = (remainingSplits - 1 + 1) * (fileSize / totalSplits) - 1;//Making sure it reaches 0 } Logger.LogInfo("client.getWorkSplit(" + startSplit + ", " + endSplit + ")"); SleepIfAskedTo(); //if (this.mapper == null || this.mapperType == null) //{ GetMapperObject(mapperName, mapperCode); //} fetchItProcessItSendIt(startSplit, endSplit, remainingSplits); status = ExecutionState.WAITING; Logger.LogInfo("client.finishedProcessingSplit(" + startSplit + ", " + endSplit + ")"); LogEndSplit(id, totalSplits, remainingSplits); processedSplits++; if (remainingSplits == 1) { IWorker wasIDeadWorker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); wasIDeadWorker.deadCheck(myURL); } } } return true; } catch (Exception e) { Logger.LogErr("Exception: " + e.ToString()); } return true; }
public bool FetchWorker(string clientURL, string jobTrackerURL, string mapperName, byte[] mapperCode, long fileSize, long totalSplits, long remainingSplits, string backURL, bool propagateRemainingSplits) { try { /* wait until if I am unfrozen */ WaitForUnfreeze(); /* --------------------------- */ //dead node revived!!! nooooooooo ! if (!backURL.Equals(this.backURL)) { Logger.LogInfo("Receiving work from the Dead. Invoking Node Registration"); //do stuff to recover that node back to the network IWorker revivedWorker = (IWorker)Activator.GetObject(typeof(IWorker), backURL); RecoverDeadNodeAsyncDel deadDel = new RecoverDeadNodeAsyncDel(revivedWorker.Register); IAsyncResult deadResponse = deadDel.BeginInvoke(currentJobTrackerUrl, null, null); return(true); } currentJobTrackerUrl = jobTrackerURL; currentJobTracker = (IWorker)Activator.GetObject(typeof(IWorker), currentJobTrackerUrl); backupWorkData(status, clientURL, jobTrackerURL, mapperName, mapperCode, fileSize, totalSplits, remainingSplits); IWorker worker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(worker.FetchWorker); Thread liveCheck = new Thread(this.liveCheck); if (serverRole == ServerRole.JOB_TRACKER) { IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, true, null, null); liveCheck.Start(RemAr); } else { if (!didRegisted) { RegisterAtJobTracker(); didRegisted = true; } if (status == ExecutionState.WORKING && propagateRemainingSplits) { Logger.LogInfo("[JT FORWARD] Forwarded work from JobTracker: " + currentJobTrackerUrl + " remainingSplits: " + remainingSplits); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, true, null, null); liveCheck.Start(RemAr); } else { Logger.LogInfo("[RECEIVED SPLIT] Received Work from JobTracker: " + currentJobTrackerUrl + " remainingSplits: " + remainingSplits); LogStartSplit(id, fileSize, totalSplits, remainingSplits); serverRole = ServerRole.WORKER; status = ExecutionState.WORKING; this.clientURL = clientURL; client = (IClient)Activator.GetObject(typeof(IClient), clientURL); if (remainingSplits > 1 && propagateRemainingSplits) { Logger.LogInfo("[WORKER FORWARD NEXT SPLIT]"); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, currentJobTrackerUrl, mapperName, mapperCode, fileSize, totalSplits, remainingSplits - 1, myURL, true, null, null); liveCheck.Start(RemAr); } long startSplit = (remainingSplits - 1) * (fileSize / totalSplits); long endSplit; if (remainingSplits == totalSplits) { endSplit = fileSize; } else { endSplit = (remainingSplits - 1 + 1) * (fileSize / totalSplits) - 1;//Making sure it reaches 0 } Logger.LogInfo("client.getWorkSplit(" + startSplit + ", " + endSplit + ")"); SleepIfAskedTo(); //if (this.mapper == null || this.mapperType == null) //{ GetMapperObject(mapperName, mapperCode); //} fetchItProcessItSendIt(startSplit, endSplit, remainingSplits); status = ExecutionState.WAITING; Logger.LogInfo("client.finishedProcessingSplit(" + startSplit + ", " + endSplit + ")"); LogEndSplit(id, totalSplits, remainingSplits); processedSplits++; if (remainingSplits == 1) { IWorker wasIDeadWorker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); wasIDeadWorker.deadCheck(myURL); } } } return(true); } catch (Exception e) { Logger.LogErr("Exception: " + e.ToString()); } return(true); }
private void ResendSplitToNextWorker(IWorker worker, long fileSize, long totalSplits, long remainingSplits) { FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(worker.FetchWorker); Thread liveCheck = new Thread(this.liveCheck); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, myURL, mapperName, mapperCode, fileSize, totalSplits, remainingSplits, myURL, false, null, null); liveCheck.Start(RemAr); }
public void ReceiveWork(string clientURL, long fileSize, long splits, string mapperName, byte[] mapperCode) { try { Logger.LogInfo("Received: " + clientURL + " with " + splits + " splits fileSize =" + fileSize); if (!didStartedPrimaryProcess) { StartPrimaryJobTrackerProcess(clientURL, fileSize, splits, mapperName, mapperCode); didStartedPrimaryProcess = true; } /* wait until if I am unfrozen and revert to Worker if needed */ Logger.LogWarn("Testing in freeze state"); WaitForUnfreezeAndCheckChanges(); /* --------------------------- */ IWorker nextWorker = (IWorker)Activator.GetObject(typeof(IWorker), nextURL); if (splits > fileSize) splits = fileSize; long splitSize = fileSize / splits; FetchWorkerAsyncDel RemoteDel = new FetchWorkerAsyncDel(nextWorker.FetchWorker); IAsyncResult RemAr = RemoteDel.BeginInvoke(clientURL, myURL, mapperName, mapperCode, fileSize, splits, splits, myURL, true, null, null); if (secondaryJT == null) { Logger.LogErr("Job tracker backup hasn't been configured yet"); secondaryJT.PrimaryStartedJob(); } return; } catch (RemotingException e) { Logger.LogErr("Remoting Exception: " + e.Message); } }