Пример #1
0
        public void Post(DeleteFile request)
        {
            logger.Info("****Request received for deleting file : " + request.filepath + " owned by user : "******"Authentication failed");
                }

                FileMetaData metadata = filesystem.getFileMetaDataCloneSynchronized(request.clientId, request.password, request.filepath);

                FileServerComm serverComm     = FileServerComm.getInstance();
                Address []     memberAdresses = serverComm.getFileServerGroup().getLiveMembers();

                List <Address> where = new List <Address> ();
                where.AddRange(memberAdresses);

                if (true == serverComm.getFileHandler().sendsynchdeleteFile(metadata, serverComm.getOOBHandler(),
                                                                            serverComm.getFileServerGroup()))
                {
                    bool delete = filesystem.deleteFileSynchronized(request.clientId, request.filepath);

                    if (!delete)
                    {
                        logger.Debug("The file : " + request.filepath + " was already marked for deletion, skipping");
                    }
                }
            } catch (Exception e) {
                logger.Warn(e);
                throw e;
            }
        }
Пример #2
0
        public void Post(UnShareFileWithUser request)
        {
            logger.Info("****Request received for un-sharing file owned by user : "******" by user : "******" for file name : " + request.filename
                        );
            if (!filesystem.AuthenticateUser(request.clientId, request.password))
            {
                throw new AuthenticationException("Authentication failed");
            }

            FileServerComm serverComm = FileServerComm.getInstance();

            Address [] memberAdresses = serverComm.getFileServerGroup().getLiveMembers();

            List <Address> where = new List <Address> ();
            where.AddRange(memberAdresses);

            try {
                if (true == serverComm.getFileHandler().sendSynchUnShareRequest(request, serverComm.getOOBHandler(),
                                                                                serverComm.getFileServerGroup()))
                {
                    filesystem.unShareFileWithUser(request.clientId, request.filename, request.sharedWithUser);
                }
                else
                {
                    throw new Exception("Internal Server Error");
                }
            } catch (Exception e) {
                logger.Warn(e);
                throw e;
            }
        }
Пример #3
0
 void handleBootStrappingEnd(BootStrappingCheckPoint request)
 {
     Logger.Debug("handleBootStrappingEnd , Response received from " + request.nodeAddress.ToStringVerboseFormat());
     if (null != state.selectedNode && request.nodeAddress.Equals(state.selectedNode))
     {
         Logger.Debug("handleBootStrappingEnd :)");
         state.currState = eBootStrapState.BootStrappingComplete;
         FileServerComm fileSrvComm = FileServerComm.getInstance();
         doDiff(fileSrvComm.getFileHandler().filesystem);
         state.cancelBootStrappingTimer();
         waitBootStrap.Release();
         Logger.Debug("handleBootStrappingEnd :) Finally Done");
     }
     else
     {
         Logger.Debug("handleBootStrappingEnd, Receieved from Another Node, Some Problem. Ignore this Plz :)");
     }
 }
Пример #4
0
        public void Post(AddUser request)
        {
            logger.Info("****Request received for adding user with client id :" + request.clientId
                        + " and password : "******"User is already present in inmemory map, throwing back exception");
                        throw new Exception("User is already present in memory");
                    }
                    else
                    {
                        logger.Debug("User added succesfully");
                    }
                } catch (Exception e) {
                    logger.Debug(e);
                    throw e;
                }
            }
            else
            {
                throw new Exception("User Add Exception");
            }
        }
Пример #5
0
            public override void Configure(Funq.Container container)
            {
                Plugins.Add(new RequestLogsFeature());
                this.Config.DefaultContentType = "Json";
                //container.RegisterAutoWired<InMemoryFileSystem>();

                InMemoryFileSystem fileSystem = new InMemoryFileSystem();

                container.Register <InMemoryFileSystem> (fileSystem);

                Console.WriteLine("Application_Start ---->. Begin");

                //Start the ISIS System
                IsisSystem.Start();

                Console.WriteLine("ISIS Started :)");

                FileServerComm.fileServerGroupName = "FileServer";
                FileServerComm fileSrvComm = FileServerComm.getInstance();

                fileSrvComm.getFileHandler().filesystem = fileSystem;

                System.IO.StreamReader file = new System.IO.StreamReader("bootstrap.txt");
                string line = file.ReadLine();

                Console.WriteLine(line);

                bool isBootStrap = false;

                if (line.Equals("1"))
                {
                    isBootStrap = true;
                }

                fileSrvComm.ApplicationStartup(isBootStrap, FileServerComm.fileServerGroupName);

                Console.WriteLine("Application_Start. End");
            }
Пример #6
0
        public void Post(UpdateFile request)
        {
            logger.Info("****Request received for updating user file for client id  : " + request.clientId
                        + " and file name : " + request.file.filemetadata.filepath
                        );

            if (!filesystem.AuthenticateUser(request.clientId, request.password))
            {
                throw new AuthenticationException("Authentication failed");
            }

            // Send the File to the All other Nodes in a Ordered Way
            FileServerComm serverComm = FileServerComm.getInstance();

            Address [] memberAdresses = serverComm.getFileServerGroup().getLiveMembers();

            List <Address> where = new List <Address>();
            where.AddRange(memberAdresses);

            if (true == serverComm.getFileHandler().sendsynchaddFileToMemory(request.clientId, request.file,
                                                                             serverComm.getOOBHandler(), serverComm.getFileServerGroup(),
                                                                             where))
            {
                try {
                    filesystem.addFileSynchronized(request.clientId, request.file);
                } catch (Exception e) {
                    logger.Debug("Exception occured while updating user file for client id  : " + request.clientId
                                 + " and file name : " + request.file.filemetadata.filepath, e);
                    throw e;
                }
            }
            else
            {
                throw new Exception("File Cannot be Added, Some Internal error");
            }
        }