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


C# Group.RawP2PSend方法代码示例

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


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

示例1: handleBootStrappingRequest

        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);
//.........这里部分代码省略.........
开发者ID:piyushmh,项目名称:cloud-filesystem,代码行数:101,代码来源:BootStrap.cs

示例2: sendBootStrappingRequest

        public void sendBootStrappingRequest(Group group, Address lastSelectedNode)
        {
            Address [] liveMembers = group.getLiveMembers ();
            Address myAddress = IsisSystem.GetMyAddress ();

            if (liveMembers.Length > 1) {
                Random rnd = new Random ();

                int sendNodeIndex = 0;
                int numTries = 0;

                do {
                    sendNodeIndex = rnd.Next (0, liveMembers.Length);
                    if (liveMembers [sendNodeIndex].Equals (myAddress)) {
                        continue;
                    }
                    Logger.Debug ("Stuck in a Infinite Loop : Length: " + liveMembers.Length);
                    numTries = numTries + 1;
                    break;
                } while(true);

                if (numTries != liveMembers.Length) {
                    Logger.Debug ("sendBootStrappingRequest Succeeded :). Sending to Address " + liveMembers [sendNodeIndex].ToStringVerboseFormat ());
                    Logger.Debug ("My Address is :) " + IsisSystem.GetMyAddress ().ToStringVerboseFormat ());

                    BootStrappingRequest request = new BootStrappingRequest (IsisSystem.GetMyAddress (),
                                                            FileServerComm.getInstance ().transManager.generateTransactionId ());
                    state.selectedNode = liveMembers [sendNodeIndex];
                    state.currState = eBootStrapState.SentBootStrappingBeginRequest;

                    group.RawP2PSend (liveMembers [sendNodeIndex], FileServerComm.BootStrapRequest, request);
                } else {
                    Logger.Debug ("sendBootStrappingRequest Failed :) Try After Backup");
                    state.selectedNode = lastSelectedNode;
                    state.currState = eBootStrapState.Initialized;
                    state.setBootStrappingTimer (group, this);
                }
            } else {
                Logger.Debug("There are No Live Members Available, Just Continue :  " + liveMembers.Length);
                state.currState = eBootStrapState.BootStrappingComplete;
                waitBootStrap.Release();
            }
        }
开发者ID:piyushmh,项目名称:cloud-filesystem,代码行数:43,代码来源:BootStrap.cs


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