Ejemplo n.º 1
0
        public void handleAddUser(object arg)
        {
            try {
                Logger.Debug("Update addUser To Memory Synchronized - Begin");
                OOBTransaction request    = (OOBTransaction)arg;
                UserFileSystem fileSystem = null;

                Group      group     = FileServerComm.getInstance().getFileServerGroup();
                OOBHandler oobhandle = FileServerComm.getInstance().getOOBHandler();

                MemoryMappedFile transferredFile = group.OOBFetch(request.transactionID);

                if (null != transferredFile)
                {
                    Logger.Debug("AddUser for OOB Fetch Success :)");
                    int index = 0;
                    fileSystem = oobhandle.deserializeFromMemoryMappedFile(transferredFile, ref index, request.fileLength) as UserFileSystem;
                    Logger.Debug("Received User is " + fileSystem.ToString());
                }
                else
                {
                    Logger.Debug("AddUser for OOB Fetch Success :(");
                }
                group.OOBDelete(request.transactionID);

                TryReleaseLock(request.initiatedSystemId, request.transactionID);
                Logger.Debug("Update addUser To Memory Synchronized - End");
            } catch (Exception e) {
                Logger.Debug("Update addUser To Memory Synchronized encountered exception " + e.ToString());
            }
        }
Ejemplo n.º 2
0
        /*
         *      This Function is called when a New File Needs to be Added into the memory
         */
        public bool sendsynchaddFileToMemory(string UserName, UserFile file, OOBHandler oobhandle, Group group, List <Address> where)
        {
            try {
                Logger.Debug("File Operations Synch - sendsynchaddFileToMemory >> BEGIN");
                bool             operationResult = false;
                MemoryMappedFile transferFile    = null;

                string      fileName = FileServerComm.getInstance().transManager.generateTransactionId(UserName + "_" + file.filemetadata.filepath);
                Transaction trans    = new Transaction(fileName);

                if (true == FileServerComm.getInstance().transManager.insertTransaction(trans))
                {
                    try {
                        int writtenBytesLength = 0;
                        transferFile = oobhandle.serializeIntoMemoryMappedFile(fileName, file, ref writtenBytesLength);

                        oobhandle.sendOOBData(group, transferFile, fileName, where);

                        trans.waitTillSignalled();
                        Logger.Debug("File Operations Synch - sendsynchaddFileToMemory >> OOB Transfer of Data Complete for : "
                                     + file.filemetadata.filepath);

                        operationResult = !trans.isTimedOut;

                        OOBTransaction oobtrabs = new OOBTransaction(fileName, IsisSystem.GetMyAddress(), writtenBytesLength);

                        if (operationResult)
                        {
                            group.OrderedSend(FileServerComm.SaveFileToMemory, oobtrabs);
                            trans.waitTillSignalled();
                            Logger.Debug("File Operations Synch - sendsynchaddFileToMemory >> Ordered Send Complete Complete for : "
                                         + file.filemetadata.filepath);
                            operationResult = !trans.isTimedOut;
                        }
                        FileServerComm.getInstance().transManager.removeAndGetTransaction(fileName);
                        operationResult = !trans.isTimedOut;
                    } catch (Exception e) {
                        Logger.Debug("Exception during File Operations Synch - sendsynchaddFileToMemory" + e.ToString());
                        FileServerComm.getInstance().transManager.removeAndGetTransaction(fileName);
                        operationResult = false;
                    }
                }
                else
                {
                    Logger.Debug("File Operations Synch - sendsynchaddFileToMemory >> Generation of Transaction ID Failed: " + fileName);
                }
                return(operationResult);
            } catch (Exception e) {
                Logger.Debug("Caught Exception " + e.ToString());
            }
            return(false);
        }
Ejemplo n.º 3
0
        /*
         * This Function is to be Called when a Entire User Needs to be Moved
         */
        public bool sendsynchUser(UserFileSystem file, OOBHandler oobhandle, Group group, List <Address> where)
        {
            try {
                Logger.Debug("File Operations Synch - sendsynchUser >> BEGIN");
                bool   operationResult = false;
                string fileName        = FileServerComm.getInstance().transManager.generateTransactionId(file.metadata.clientId);

                Transaction trans = new Transaction(fileName);

                if (true == FileServerComm.getInstance().transManager.insertTransaction(trans))
                {
                    try {
                        MemoryMappedFile transferFile = null;
                        int writtenBytesLength        = 0;
                        transferFile = oobhandle.serializeIntoMemoryMappedFile(fileName, file, ref writtenBytesLength);

                        OOBTransaction oobtrabs = new OOBTransaction(fileName, IsisSystem.GetMyAddress(), writtenBytesLength);
                        oobhandle.sendOOBData(group, transferFile, fileName, where);

                        trans.waitTillSignalled();
                        operationResult = !trans.isTimedOut;

                        if (operationResult)
                        {
                            group.OrderedSend(FileServerComm.UpdateUser, oobtrabs);
                            trans.waitTillSignalled();
                            operationResult = !trans.isTimedOut;
                        }
                        FileServerComm.getInstance().transManager.removeAndGetTransaction(fileName);
                        operationResult = !trans.isTimedOut;
                    } catch (Exception e) {
                        Logger.Debug("Exception during File Operations Synch - sendsynchUser" + e.ToString());
                    }
                }

                return(operationResult);
            } catch (Exception e) {
                Logger.Debug("File Operations Synch - sendsynchUser >> Encountered Exception : " + e.ToString());
                return(false);
            }
        }
Ejemplo n.º 4
0
        /*
         * Handler Function which Adds a File into Memory
         */
        public void handleAddFileToMemory(object arg)
        {
            try {
                OOBTransaction request     = (OOBTransaction)arg;
                UserFile       userfilesys = null;
                Logger.Debug("Update addFileToMemory Data Synchronized - Begin");

                Group      group     = FileServerComm.getInstance().getFileServerGroup();
                OOBHandler oobhandle = FileServerComm.getInstance().getOOBHandler();

                MemoryMappedFile transferredFile = group.OOBFetch(request.transactionID);

                if (null != transferredFile)
                {
                    Logger.Debug("getUserFileInfo OOB Fetch Success :)");
                    int index = 0;
                    userfilesys = oobhandle.deserializeFromMemoryMappedFile(transferredFile, ref index, request.fileLength) as UserFile;
                }
                else
                {
                    Logger.Debug("getUserFileInfo Failed Reason: OOB Fetch Failed:)");
                }

                if (!request.initiatedSystemId.Equals(IsisSystem.GetMyAddress()) &&
                    null != userfilesys)
                {
                    filesystem.addFileSynchronized(userfilesys.filemetadata.owner, userfilesys);
                }
                group.OOBDelete(request.transactionID);

                TryReleaseLock(request.initiatedSystemId, request.transactionID);
                Logger.Debug("Update addFileToMemory Data Synchronized - End");
            } catch (Exception e) {
                Logger.Debug("Update addFileToMemory Data Synchronized encountered an exception " + e.ToString());
            }
        }
Ejemplo n.º 5
0
        /*
         * This Function is to be Called when a Entire User Needs to be Moved
        */
        public bool sendsynchUser(UserFileSystem file, OOBHandler oobhandle, Group group, List<Address> where)
        {
            try {
                Logger.Debug ("File Operations Synch - sendsynchUser >> BEGIN");
                bool operationResult = false;
                string fileName = FileServerComm.getInstance ().transManager.generateTransactionId (file.metadata.clientId);

                Transaction trans = new Transaction (fileName);

                if (true == FileServerComm.getInstance ().transManager.insertTransaction (trans)) {
                    try {
                        MemoryMappedFile transferFile = null;
                        int writtenBytesLength = 0;
                        transferFile = oobhandle.serializeIntoMemoryMappedFile (fileName, file, ref writtenBytesLength);

                        OOBTransaction oobtrabs = new OOBTransaction (fileName, IsisSystem.GetMyAddress (), writtenBytesLength);
                        oobhandle.sendOOBData (group, transferFile, fileName, where);

                        trans.waitTillSignalled ();
                        operationResult = !trans.isTimedOut;

                        if (operationResult) {
                            group.OrderedSend (FileServerComm.UpdateUser, oobtrabs);
                            trans.waitTillSignalled ();
                            operationResult = !trans.isTimedOut;
                        }
                        FileServerComm.getInstance ().transManager.removeAndGetTransaction (fileName);
                        operationResult = !trans.isTimedOut;
                    } catch (Exception e) {
                        Logger.Debug ("Exception during File Operations Synch - sendsynchUser" + e.ToString ());
                    }
                }

                return operationResult;
            } catch (Exception e) {
                Logger.Debug ("File Operations Synch - sendsynchUser >> Encountered Exception : " + e.ToString());
                return false;
            }
        }
Ejemplo n.º 6
0
        /*
            This Function is called when a New File Needs to be Added into the memory
         */
        public bool sendsynchaddFileToMemory(string UserName, UserFile file, OOBHandler oobhandle, Group group, List<Address> where)
        {
            try {
                Logger.Debug ("File Operations Synch - sendsynchaddFileToMemory >> BEGIN");
                bool operationResult = false;
                MemoryMappedFile transferFile = null;

                string fileName = FileServerComm.getInstance ().transManager.generateTransactionId (UserName + "_" + file.filemetadata.filepath);
                Transaction trans = new Transaction (fileName);

                if (true == FileServerComm.getInstance ().transManager.insertTransaction (trans)) {
                    try {

                        int writtenBytesLength = 0;
                        transferFile = oobhandle.serializeIntoMemoryMappedFile (fileName, file,ref writtenBytesLength);

                        oobhandle.sendOOBData (group, transferFile, fileName, where);

                        trans.waitTillSignalled ();
                        Logger.Debug ("File Operations Synch - sendsynchaddFileToMemory >> OOB Transfer of Data Complete for : "
                                      + file.filemetadata.filepath);

                        operationResult = !trans.isTimedOut;

                        OOBTransaction oobtrabs = new OOBTransaction (fileName, IsisSystem.GetMyAddress (), writtenBytesLength);

                        if (operationResult) {
                            group.OrderedSend (FileServerComm.SaveFileToMemory, oobtrabs);
                            trans.waitTillSignalled ();
                            Logger.Debug ("File Operations Synch - sendsynchaddFileToMemory >> Ordered Send Complete Complete for : "
                                          + file.filemetadata.filepath);
                            operationResult = !trans.isTimedOut;
                        }
                        FileServerComm.getInstance ().transManager.removeAndGetTransaction (fileName);
                        operationResult = !trans.isTimedOut;
                    } catch (Exception e) {
                        Logger.Debug ("Exception during File Operations Synch - sendsynchaddFileToMemory" + e.ToString ());
                        FileServerComm.getInstance ().transManager.removeAndGetTransaction (fileName);
                        operationResult = false;
                    }
                } else {
                    Logger.Debug ("File Operations Synch - sendsynchaddFileToMemory >> Generation of Transaction ID Failed: " + fileName);
                }
                return operationResult;
            } catch (Exception e) {
                Logger.Debug("Caught Exception " + e.ToString());
            }
            return false;
        }