示例#1
0
        public String Open(String filename)
        {
            log.Debug(DateTime.Now.Ticks + " Open: " + filename);


            Console.WriteLine("#OPEN  Open: " + filename);
            //            if (GetFileMetadataEntry(filename) != null)
            //              throw new PadiException(PadiExceptiontType.OpenFile, "ClientCore: File already opened: " + filename);

            RequestOpen openRequest = new RequestOpen(filename);

            log.Debug(DateTime.Now.Ticks + " [M] Send Open: " + filename);
            MetaserverResponse response  = MetaserverClient.SendRequestToMetaserver(openRequest);
            MetadataEntry      metaEntry = response.MetaEntry;

            if (metaEntry == null)
            {
                throw new PadiException(PadiExceptiontType.OpenFile, "Response without entry");
            }

            if (GetFileMetadataEntry(filename) != null)
            {
                UpdateMetadataEntry(metaEntry);
                Console.WriteLine("#Open: Value Updated");
                log.Debug(DateTime.Now.Ticks + " Open Done: " + filename);
                return(metaEntry.ToString());
            }

            AddFileMetadataEntry(metaEntry);
            log.Debug(DateTime.Now.Ticks + " Open done: " + filename);
            Console.WriteLine("#Open: Complete");
            return(metaEntry.ToString());
        }
示例#2
0
        //////////////////////////////////// CLient Interface //////////////////////////////////
        public String Create(String filename, int nbDataServers, int readQuorum, int writeQuorum)
        {
            log.Debug(DateTime.Now.Ticks + " Create: " + filename);

            Console.WriteLine("#CREATE Create file: " + filename + " nbDataServer: " + nbDataServers + " readQuorum: " + readQuorum + " writeQuorum: " + writeQuorum);
            RequestCreate createRequest = new RequestCreate(filename, nbDataServers, readQuorum, writeQuorum);

            log.Debug(DateTime.Now.Ticks + " [M] Send Create: " + filename);
            MetaserverResponse response = MetaserverClient.SendRequestToMetaserver(createRequest);
            //Processar a resposta
            MetadataEntry metaEntry = response.MetaEntry;

            if (metaEntry != null)
            {
                Console.WriteLine("#CREATE Create Successeful");
                log.Debug(DateTime.Now.Ticks + " Create Done: " + filename);
                return(metaEntry.ToString( ));
            }
            else
            {
                throw new PadiException(PadiExceptiontType.CreateFile, "Response without entry");
            }
        }