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


C# Group.P2PSend方法代码示例

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


在下文中一共展示了Group.P2PSend方法的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: handleBootStrappingContinue

        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 :)");
            }
        }
开发者ID:piyushmh,项目名称:cloud-filesystem,代码行数:52,代码来源:BootStrap.cs


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