Exemple #1
0
        public static READDIR3Response Deserialize(XDR xdr)
        {
            int status = xdr.ReadInt();

            xdr.ReadBoolean();
            Nfs3FileAttributes postOpDirAttr = Nfs3FileAttributes.Deserialize(xdr);
            long cookieVerf = 0;
            AList <READDIR3Response.Entry3> entries = new AList <READDIR3Response.Entry3>();

            READDIR3Response.DirList3 dirList = null;
            if (status == Nfs3Status.Nfs3Ok)
            {
                cookieVerf = xdr.ReadHyper();
                while (xdr.ReadBoolean())
                {
                    READDIR3Response.Entry3 e = READDIR3Response.Entry3.Deserialzie(xdr);
                    entries.AddItem(e);
                }
                bool eof = xdr.ReadBoolean();
                READDIR3Response.Entry3[] allEntries = new READDIR3Response.Entry3[entries.Count]
                ;
                Collections.ToArray(entries, allEntries);
                dirList = new READDIR3Response.DirList3(allEntries, eof);
            }
            return(new READDIR3Response(status, postOpDirAttr, cookieVerf, dirList));
        }
Exemple #2
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.PATHCONF3Response Deserialize(XDR
                                                                                        xdr)
        {
            int status = xdr.ReadInt();

            xdr.ReadBoolean();
            Nfs3FileAttributes objPostOpAttr = Nfs3FileAttributes.Deserialize(xdr);
            int  linkMax         = 0;
            int  nameMax         = 0;
            bool noTrunc         = false;
            bool chownRestricted = false;
            bool caseInsensitive = false;
            bool casePreserving  = false;

            if (status == Nfs3Status.Nfs3Ok)
            {
                linkMax         = xdr.ReadInt();
                nameMax         = xdr.ReadInt();
                noTrunc         = xdr.ReadBoolean();
                chownRestricted = xdr.ReadBoolean();
                caseInsensitive = xdr.ReadBoolean();
                casePreserving  = xdr.ReadBoolean();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.PATHCONF3Response(status, objPostOpAttr
                                                                             , linkMax, nameMax, noTrunc, chownRestricted, caseInsensitive, casePreserving));
        }
Exemple #3
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.WccData Deserialize(XDR xdr)
        {
            xdr.ReadBoolean();
            WccAttr preOpAttr = WccAttr.Deserialize(xdr);

            xdr.ReadBoolean();
            Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.Deserialize(xdr);

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.WccData(preOpAttr, postOpAttr));
        }
Exemple #4
0
        public virtual void Deserialize(XDR xdr)
        {
            if (xdr.ReadBoolean())
            {
                mode = xdr.ReadInt();
                updateFields.AddItem(SetAttr3.SetAttrField.Mode);
            }
            if (xdr.ReadBoolean())
            {
                uid = xdr.ReadInt();
                updateFields.AddItem(SetAttr3.SetAttrField.Uid);
            }
            if (xdr.ReadBoolean())
            {
                gid = xdr.ReadInt();
                updateFields.AddItem(SetAttr3.SetAttrField.Gid);
            }
            if (xdr.ReadBoolean())
            {
                size = xdr.ReadHyper();
                updateFields.AddItem(SetAttr3.SetAttrField.Size);
            }
            int timeSetHow = xdr.ReadInt();

            if (timeSetHow == TimeSetToClientTime)
            {
                atime = NfsTime.Deserialize(xdr);
                updateFields.AddItem(SetAttr3.SetAttrField.Atime);
            }
            else
            {
                if (timeSetHow == TimeSetToServerTime)
                {
                    atime = new NfsTime(Runtime.CurrentTimeMillis());
                    updateFields.AddItem(SetAttr3.SetAttrField.Atime);
                }
            }
            timeSetHow = xdr.ReadInt();
            if (timeSetHow == TimeSetToClientTime)
            {
                mtime = NfsTime.Deserialize(xdr);
                updateFields.AddItem(SetAttr3.SetAttrField.Mtime);
            }
            else
            {
                if (timeSetHow == TimeSetToServerTime)
                {
                    mtime = new NfsTime(Runtime.CurrentTimeMillis());
                    updateFields.AddItem(SetAttr3.SetAttrField.Mtime);
                }
            }
        }
            public override void MessageReceived(ChannelHandlerContext ctx, MessageEvent e)
            {
                // Get handle from create response
                ChannelBuffer buf = (ChannelBuffer)e.GetMessage();
                XDR           rsp = new XDR(buf.Array());

                if (rsp.GetBytes().Length == 0)
                {
                    Log.Info("rsp length is zero, why?");
                    return;
                }
                Log.Info("rsp length=" + rsp.GetBytes().Length);
                RpcReply reply = RpcReply.Read(rsp);
                int      xid   = reply.GetXid();

                // Only process the create response
                if (xid != unchecked ((int)(0x8000004c)))
                {
                    return;
                }
                int status = rsp.ReadInt();

                if (status != Nfs3Status.Nfs3Ok)
                {
                    Log.Error("Create failed, status =" + status);
                    return;
                }
                Log.Info("Create succeeded");
                rsp.ReadBoolean();
                // value follow
                handle = new FileHandle();
                handle.Deserialize(rsp);
                channel = e.GetChannel();
            }
Exemple #6
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.FSINFO3Response Deserialize(XDR
                                                                                      xdr)
        {
            int status = xdr.ReadInt();

            xdr.ReadBoolean();
            Nfs3FileAttributes postOpObjAttr = Nfs3FileAttributes.Deserialize(xdr);
            int     rtmax       = 0;
            int     rtpref      = 0;
            int     rtmult      = 0;
            int     wtmax       = 0;
            int     wtpref      = 0;
            int     wtmult      = 0;
            int     dtpref      = 0;
            long    maxFileSize = 0;
            NfsTime timeDelta   = null;
            int     properties  = 0;

            if (status == Nfs3Status.Nfs3Ok)
            {
                rtmax       = xdr.ReadInt();
                rtpref      = xdr.ReadInt();
                rtmult      = xdr.ReadInt();
                wtmax       = xdr.ReadInt();
                wtpref      = xdr.ReadInt();
                wtmult      = xdr.ReadInt();
                dtpref      = xdr.ReadInt();
                maxFileSize = xdr.ReadHyper();
                timeDelta   = NfsTime.Deserialize(xdr);
                properties  = xdr.ReadInt();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.FSINFO3Response(status, postOpObjAttr
                                                                           , rtmax, rtpref, rtmult, wtmax, wtpref, wtmult, dtpref, maxFileSize, timeDelta,
                                                                           properties));
        }
Exemple #7
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.FSSTAT3Response Deserialize(XDR
                                                                                      xdr)
        {
            int status = xdr.ReadInt();

            xdr.ReadBoolean();
            Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.Deserialize(xdr);
            long tbytes   = 0;
            long fbytes   = 0;
            long abytes   = 0;
            long tfiles   = 0;
            long ffiles   = 0;
            long afiles   = 0;
            int  invarsec = 0;

            if (status == Nfs3Status.Nfs3Ok)
            {
                tbytes   = xdr.ReadHyper();
                fbytes   = xdr.ReadHyper();
                abytes   = xdr.ReadHyper();
                tfiles   = xdr.ReadHyper();
                ffiles   = xdr.ReadHyper();
                afiles   = xdr.ReadHyper();
                invarsec = xdr.ReadInt();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.FSSTAT3Response(status, postOpAttr
                                                                           , tbytes, fbytes, abytes, tfiles, ffiles, afiles, invarsec));
        }
        /// <exception cref="System.IO.IOException"/>
        public LOOKUP3Response(XDR xdr)
            : base(-1)
        {
            fileHandle = new FileHandle();
            status     = xdr.ReadInt();
            Nfs3FileAttributes objAttr = null;

            if (status == Nfs3Status.Nfs3Ok)
            {
                if (!fileHandle.Deserialize(xdr))
                {
                    throw new IOException("can't deserialize file handle");
                }
                objAttr = xdr.ReadBoolean() ? Nfs3FileAttributes.Deserialize(xdr) : null;
            }
            postOpObjAttr = objAttr;
            postOpDirAttr = xdr.ReadBoolean() ? Nfs3FileAttributes.Deserialize(xdr) : null;
        }
Exemple #9
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.MKDIR3Response Deserialize(XDR
                                                                                     xdr)
        {
            int                status        = xdr.ReadInt();
            FileHandle         objFileHandle = new FileHandle();
            Nfs3FileAttributes objAttr       = null;
            WccData            dirWcc;

            if (status == Nfs3Status.Nfs3Ok)
            {
                xdr.ReadBoolean();
                objFileHandle.Deserialize(xdr);
                xdr.ReadBoolean();
                objAttr = Nfs3FileAttributes.Deserialize(xdr);
            }
            dirWcc = WccData.Deserialize(xdr);
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.MKDIR3Response(status, objFileHandle
                                                                          , objAttr, dirWcc));
        }
Exemple #10
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.READ3Response Deserialize(XDR xdr
                                                                                    )
        {
            int status = xdr.ReadInt();

            xdr.ReadBoolean();
            Nfs3FileAttributes postOpAttr = Nfs3FileAttributes.Deserialize(xdr);
            int  count = 0;
            bool eof   = false;

            byte[] data = new byte[0];
            if (status == Nfs3Status.Nfs3Ok)
            {
                count = xdr.ReadInt();
                eof   = xdr.ReadBoolean();
                int len = xdr.ReadInt();
                System.Diagnostics.Debug.Assert((len == count));
                data = xdr.ReadFixedOpaque(count);
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.READ3Response(status, postOpAttr,
                                                                         count, eof, ByteBuffer.Wrap(data)));
        }
            internal static READDIRPLUS3Response.EntryPlus3 Deseralize(XDR xdr)
            {
                long   fileId = xdr.ReadHyper();
                string name   = xdr.ReadString();
                long   cookie = xdr.ReadHyper();

                xdr.ReadBoolean();
                Nfs3FileAttributes nameAttr      = Nfs3FileAttributes.Deserialize(xdr);
                FileHandle         objFileHandle = new FileHandle();

                objFileHandle.Deserialize(xdr);
                return(new READDIRPLUS3Response.EntryPlus3(fileId, name, cookie, nameAttr, objFileHandle
                                                           ));
            }
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.READLINK3Response Deserialize(XDR
                                                                                        xdr)
        {
            int status = xdr.ReadInt();

            xdr.ReadBoolean();
            Nfs3FileAttributes postOpSymlinkAttr = Nfs3FileAttributes.Deserialize(xdr);

            byte[] path = new byte[0];
            if (status == Nfs3Status.Nfs3Ok)
            {
                path = xdr.ReadVariableOpaque();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.READLINK3Response(status, postOpSymlinkAttr
                                                                             , path));
        }
Exemple #13
0
        /* A client may request that the server check that the object is in an
         * expected state before performing the SETATTR operation. If guard.check is
         * TRUE, the server must compare the value of ctime to the current ctime of
         * the object. If the values are different, the server must preserve the
         * object attributes and must return a status of NFS3ERR_NOT_SYNC. If check is
         * FALSE, the server will not perform this check.
         */
        /// <exception cref="System.IO.IOException"/>
        public static Org.Apache.Hadoop.Nfs.Nfs3.Request.SETATTR3Request Deserialize(XDR
                                                                                     xdr)
        {
            FileHandle handle = ReadHandle(xdr);
            SetAttr3   attr   = new SetAttr3();

            attr.Deserialize(xdr);
            bool    check = xdr.ReadBoolean();
            NfsTime ctime;

            if (check)
            {
                ctime = NfsTime.Deserialize(xdr);
            }
            else
            {
                ctime = null;
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Request.SETATTR3Request(handle, attr, check
                                                                          , ctime));
        }