void handleBootStrappingContinue(BootStrappingCheckPoint request, Group group, OOBHandler oobhandle) { Logger.Debug("handleBootStrappingContinue , Response received from " + request.nodeAddress.ToStringVerboseFormat()); int bootStrapStatus = SUCCESS; int numberOfUsersAdded = 0; if (null != state.selectedNode && request.nodeAddress.Equals(state.selectedNode)) { Logger.Debug("handleBootStrapping Continue :)"); state.currState = eBootStrapState.ReceivingData; MemoryMappedFile transferredFile = group.OOBFetch(request.fileName); if (transferredFile != null) { Logger.Debug("File" + request.fileName + "request Transfer Successfull!"); try { int index = 0; InMemoryFileSystem tempFileSystem = null; tempFileSystem = oobhandle.deserializeFromMemoryMappedFile(transferredFile, ref index, request.dataLength) as InMemoryFileSystem; List <string> users = tempFileSystem.GetInMemoryUserList(); numberOfUsersAdded = users.Count; foreach (string user in users) { UserFileSystem userfilesys = tempFileSystem.GetClonedInMemoryUserFileSystem(user); if (null != userfilesys) { fileSystem.addFSToMapSynchronized(userfilesys, user); } } } catch (Exception e) { Logger.Debug("Exception Encountered : " + e.ToString()); bootStrapStatus = FAILURE; } } else { Logger.Debug("File" + request.fileName + "was Deleted!"); bootStrapStatus = FAILURE; } Logger.Debug("handleBootStrapping Added :)" + numberOfUsersAdded + " Users"); group.OOBDelete(request.fileName); BootStrappingResponse response = null; response = new BootStrappingResponse(request.fileName, IsisSystem.GetMyAddress(), bootStrapStatus); group.P2PSend(request.nodeAddress, FileServerComm.BootStrapResponse, response); } else { Logger.Debug("handleBootStrappingContinue, Receieved from Another Node, Some Problem. Ignore this Plz :)"); } }
void handleBootStrappingRequest(Group group, OOBHandler oobhandle, InMemoryFileSystem fileSystem, string requestName, Address recvdFrom) { if (state.currState == eBootStrapState.BootStrappingComplete) { Logger.Debug("handleBootStrappingRequest , Received from " + recvdFrom.ToStringVerboseFormat()); BootStrappingCheckPoint initialStage = null; initialStage = new BootStrappingCheckPoint ("Boot Strapping Begin", FileServerComm.BootStrapBegin, IsisSystem.GetMyAddress (), SUCCESS, 0); Logger.Debug("Sending a BootStrapping Begin , Response to " + recvdFrom.ToStringVerboseFormat()); group.RawP2PSend (recvdFrom, FileServerComm.BootStrapBegin, initialStage); MemoryMappedFile transferFile = null; int currentUserIndex = 0; int numberOfUsersCurrentBatch = 0; List<string> users = fileSystem.GetInMemoryUserList (); InMemoryFileSystem tempFileSystem = new InMemoryFileSystem (false); //Yayy Lets Begin Doing Some Boot Strapping try { Logger.Debug("Number of Users to BootStrap and Send " + users.Count); while (currentUserIndex < users.Count) { UserFileSystem userfilesys = fileSystem.GetClonedInMemoryUserFileSystem (users [currentUserIndex]); numberOfUsersCurrentBatch++; Logger.Debug("Adding User to the BootStrap : " + users[currentUserIndex]); tempFileSystem.addFSToMapSynchronized (userfilesys, users [currentUserIndex]); currentUserIndex++; if (numberOfUsersCurrentBatch == BatchSize) { //Let's Make a OOB File and Transfer the Data string currentFileName = FileServerComm.getInstance ().transManager.generateTransactionId (); bool operationResult = false; numberOfUsersCurrentBatch = 0; Transaction trans = new Transaction (currentFileName); FileServerComm.getInstance ().transManager.insertTransaction (trans); int writtenBytesLength = 0; transferFile = oobhandle.serializeIntoMemoryMappedFile (currentFileName, tempFileSystem, ref writtenBytesLength); BootStrappingCheckPoint continueBootStrap = null; continueBootStrap = new BootStrappingCheckPoint (currentFileName, FileServerComm.BootStrapContinue, IsisSystem.GetMyAddress (), SUCCESS, writtenBytesLength); List<Address> where = new List<Address>(); where.Add(recvdFrom); where.Add (IsisSystem.GetMyAddress ()); oobhandle.sendOOBData (group, transferFile, currentFileName, where); trans.waitTillSignalled (); operationResult = !trans.isTimedOut; if (operationResult) { group.RawP2PSend (recvdFrom, FileServerComm.BootStrapContinue, continueBootStrap); trans.waitTillSignalled (); operationResult = !trans.isTimedOut; } else { Logger.Debug ("Sending BootStraping Request Timed Out, Quit Out of BootStrapping partcicipation"); return; } tempFileSystem = new InMemoryFileSystem (); } } //Lets Throw out the Remaining Users if (numberOfUsersCurrentBatch != 0) { string currentFileName = FileServerComm.getInstance ().transManager.generateTransactionId (); Transaction trans = new Transaction (currentFileName); FileServerComm.getInstance ().transManager.insertTransaction (trans); bool currentOperationResult = false; int writtenBytesLength = 0; transferFile = oobhandle.serializeIntoMemoryMappedFile (currentFileName, tempFileSystem, ref writtenBytesLength); BootStrappingCheckPoint _continue = null; _continue = new BootStrappingCheckPoint (currentFileName, FileServerComm.BootStrapContinue, IsisSystem.GetMyAddress (), SUCCESS, writtenBytesLength); List<Address> where = new List<Address>(); where.Add(recvdFrom); where.Add (IsisSystem.GetMyAddress ()); oobhandle.sendOOBData (group, transferFile, currentFileName, where); trans.waitTillSignalled (); currentOperationResult = !trans.isTimedOut; if (currentOperationResult) { group.RawP2PSend (recvdFrom, FileServerComm.BootStrapContinue, _continue); trans.waitTillSignalled (); currentOperationResult = !trans.isTimedOut; } else { Logger.Debug ("Sending BootStraping Request Timed Out, Quit Out of BootStrapping partcicipation"); return; } tempFileSystem = new InMemoryFileSystem (); numberOfUsersCurrentBatch = 0; } Logger.Debug("Sending a Boot Strap End Response to " + recvdFrom.ToString()); BootStrappingCheckPoint finalStage = null; finalStage = new BootStrappingCheckPoint ("Yayyy Finally Done", FileServerComm.BootStrapEnd, IsisSystem.GetMyAddress (), SUCCESS, 0); group.RawP2PSend (recvdFrom, FileServerComm.BootStrapEnd, finalStage); return; } catch (Exception e) { Logger.Debug("Caught an Exception : " + e.ToString()); BootStrappingCheckPoint _exception = null; _exception = new BootStrappingCheckPoint (e.ToString (), FileServerComm.BootStrapException, IsisSystem.GetMyAddress (), FAILURE, 0); group.P2PSend (recvdFrom, FileServerComm.BootStrapException, _exception); return; } } else { Logger.Debug("Node is Not in the State of Boot Strapping, Ignore this Request and Keep Calm"); } }
void handleBootStrappingRequest(Group group, OOBHandler oobhandle, InMemoryFileSystem fileSystem, string requestName, Address recvdFrom) { if (state.currState == eBootStrapState.BootStrappingComplete) { Logger.Debug("handleBootStrappingRequest , Received from " + recvdFrom.ToStringVerboseFormat()); BootStrappingCheckPoint initialStage = null; initialStage = new BootStrappingCheckPoint("Boot Strapping Begin", FileServerComm.BootStrapBegin, IsisSystem.GetMyAddress(), SUCCESS, 0); Logger.Debug("Sending a BootStrapping Begin , Response to " + recvdFrom.ToStringVerboseFormat()); group.RawP2PSend(recvdFrom, FileServerComm.BootStrapBegin, initialStage); MemoryMappedFile transferFile = null; int currentUserIndex = 0; int numberOfUsersCurrentBatch = 0; List <string> users = fileSystem.GetInMemoryUserList(); InMemoryFileSystem tempFileSystem = new InMemoryFileSystem(false); //Yayy Lets Begin Doing Some Boot Strapping try { Logger.Debug("Number of Users to BootStrap and Send " + users.Count); while (currentUserIndex < users.Count) { UserFileSystem userfilesys = fileSystem.GetClonedInMemoryUserFileSystem(users [currentUserIndex]); numberOfUsersCurrentBatch++; Logger.Debug("Adding User to the BootStrap : " + users[currentUserIndex]); tempFileSystem.addFSToMapSynchronized(userfilesys, users [currentUserIndex]); currentUserIndex++; if (numberOfUsersCurrentBatch == BatchSize) { //Let's Make a OOB File and Transfer the Data string currentFileName = FileServerComm.getInstance().transManager.generateTransactionId(); bool operationResult = false; numberOfUsersCurrentBatch = 0; Transaction trans = new Transaction(currentFileName); FileServerComm.getInstance().transManager.insertTransaction(trans); int writtenBytesLength = 0; transferFile = oobhandle.serializeIntoMemoryMappedFile(currentFileName, tempFileSystem, ref writtenBytesLength); BootStrappingCheckPoint continueBootStrap = null; continueBootStrap = new BootStrappingCheckPoint(currentFileName, FileServerComm.BootStrapContinue, IsisSystem.GetMyAddress(), SUCCESS, writtenBytesLength); List <Address> where = new List <Address>(); where.Add(recvdFrom); where.Add(IsisSystem.GetMyAddress()); oobhandle.sendOOBData(group, transferFile, currentFileName, where); trans.waitTillSignalled(); operationResult = !trans.isTimedOut; if (operationResult) { group.RawP2PSend(recvdFrom, FileServerComm.BootStrapContinue, continueBootStrap); trans.waitTillSignalled(); operationResult = !trans.isTimedOut; } else { Logger.Debug("Sending BootStraping Request Timed Out, Quit Out of BootStrapping partcicipation"); return; } tempFileSystem = new InMemoryFileSystem(); } } //Lets Throw out the Remaining Users if (numberOfUsersCurrentBatch != 0) { string currentFileName = FileServerComm.getInstance().transManager.generateTransactionId(); Transaction trans = new Transaction(currentFileName); FileServerComm.getInstance().transManager.insertTransaction(trans); bool currentOperationResult = false; int writtenBytesLength = 0; transferFile = oobhandle.serializeIntoMemoryMappedFile(currentFileName, tempFileSystem, ref writtenBytesLength); BootStrappingCheckPoint _continue = null; _continue = new BootStrappingCheckPoint(currentFileName, FileServerComm.BootStrapContinue, IsisSystem.GetMyAddress(), SUCCESS, writtenBytesLength); List <Address> where = new List <Address>(); where.Add(recvdFrom); where.Add(IsisSystem.GetMyAddress()); oobhandle.sendOOBData(group, transferFile, currentFileName, where); trans.waitTillSignalled(); currentOperationResult = !trans.isTimedOut; if (currentOperationResult) { group.RawP2PSend(recvdFrom, FileServerComm.BootStrapContinue, _continue); trans.waitTillSignalled(); currentOperationResult = !trans.isTimedOut; } else { Logger.Debug("Sending BootStraping Request Timed Out, Quit Out of BootStrapping partcicipation"); return; } tempFileSystem = new InMemoryFileSystem(); numberOfUsersCurrentBatch = 0; } Logger.Debug("Sending a Boot Strap End Response to " + recvdFrom.ToString()); BootStrappingCheckPoint finalStage = null; finalStage = new BootStrappingCheckPoint("Yayyy Finally Done", FileServerComm.BootStrapEnd, IsisSystem.GetMyAddress(), SUCCESS, 0); group.RawP2PSend(recvdFrom, FileServerComm.BootStrapEnd, finalStage); return; } catch (Exception e) { Logger.Debug("Caught an Exception : " + e.ToString()); BootStrappingCheckPoint _exception = null; _exception = new BootStrappingCheckPoint(e.ToString(), FileServerComm.BootStrapException, IsisSystem.GetMyAddress(), FAILURE, 0); group.P2PSend(recvdFrom, FileServerComm.BootStrapException, _exception); return; } } else { Logger.Debug("Node is Not in the State of Boot Strapping, Ignore this Request and Keep Calm"); } }