Example #1
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));
        }
Example #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));
        }
Example #3
0
        /// <exception cref="System.IO.IOException"/>
        public static Org.Apache.Hadoop.Nfs.Nfs3.Request.MKNOD3Request Deserialize(XDR xdr
                                                                                   )
        {
            FileHandle handle  = ReadHandle(xdr);
            string     name    = xdr.ReadString();
            int        type    = xdr.ReadInt();
            SetAttr3   objAttr = new SetAttr3();

            Nfs3FileAttributes.Specdata3 spec = null;
            if (type == NfsFileType.Nfschr.ToValue() || type == NfsFileType.Nfsblk.ToValue())
            {
                objAttr.Deserialize(xdr);
                spec = new Nfs3FileAttributes.Specdata3(xdr.ReadInt(), xdr.ReadInt());
            }
            else
            {
                if (type == NfsFileType.Nfssock.ToValue() || type == NfsFileType.Nfsfifo.ToValue(
                        ))
                {
                    objAttr.Deserialize(xdr);
                }
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Request.MKNOD3Request(handle, name, type, objAttr
                                                                        , spec));
        }
Example #4
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));
        }
Example #5
0
        /// <exception cref="System.IO.IOException"/>
        public static Org.Apache.Hadoop.Nfs.Nfs3.Request.READDIRPLUS3Request Deserialize(
            XDR xdr)
        {
            FileHandle handle     = ReadHandle(xdr);
            long       cookie     = xdr.ReadHyper();
            long       cookieVerf = xdr.ReadHyper();
            int        dirCount   = xdr.ReadInt();
            int        maxCount   = xdr.ReadInt();

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Request.READDIRPLUS3Request(handle, cookie,
                                                                              cookieVerf, dirCount, maxCount));
        }
Example #6
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);
                }
            }
        }
Example #7
0
        /// <exception cref="System.IO.IOException"/>
        public static Org.Apache.Hadoop.Nfs.Nfs3.Request.WRITE3Request Deserialize(XDR xdr
                                                                                   )
        {
            FileHandle handle = ReadHandle(xdr);
            long       offset = xdr.ReadHyper();
            int        count  = xdr.ReadInt();

            Nfs3Constant.WriteStableHow stableHow = Nfs3Constant.WriteStableHow.FromValue(xdr
                                                                                          .ReadInt());
            ByteBuffer data = ByteBuffer.Wrap(xdr.ReadFixedOpaque(xdr.ReadInt()));

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Request.WRITE3Request(handle, offset, count
                                                                        , stableHow, data));
        }
Example #8
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.ACCESS3Response Deserialize(XDR
                                                                                      xdr)
        {
            int status = xdr.ReadInt();
            Nfs3FileAttributes postOpAttr = null;
            int access = 0;

            if (status == Nfs3Status.Nfs3Ok)
            {
                postOpAttr = Nfs3FileAttributes.Deserialize(xdr);
                access     = xdr.ReadInt();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.ACCESS3Response(status, postOpAttr
                                                                           , access));
        }
Example #9
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));
        }
            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();
            }
Example #11
0
        /// <exception cref="System.IO.IOException"/>
        public static Org.Apache.Hadoop.Nfs.Nfs3.Request.CREATE3Request Deserialize(XDR xdr
                                                                                    )
        {
            FileHandle handle  = ReadHandle(xdr);
            string     name    = xdr.ReadString();
            int        mode    = xdr.ReadInt();
            SetAttr3   objAttr = new SetAttr3();
            long       verf    = 0;

            if ((mode == Nfs3Constant.CreateUnchecked) || (mode == Nfs3Constant.CreateGuarded
                                                           ))
            {
                objAttr.Deserialize(xdr);
            }
            else
            {
                if (mode == Nfs3Constant.CreateExclusive)
                {
                    verf = xdr.ReadHyper();
                }
                else
                {
                    throw new IOException("Wrong create mode:" + mode);
                }
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Request.CREATE3Request(handle, name, mode,
                                                                         objAttr, verf));
        }
Example #12
0
 public static Org.Apache.Hadoop.Oncrpc.Security.Credentials ReadFlavorAndCredentials
     (XDR xdr)
 {
     RpcAuthInfo.AuthFlavor flavor = RpcAuthInfo.AuthFlavor.FromValue(xdr.ReadInt());
     Org.Apache.Hadoop.Oncrpc.Security.Credentials credentials;
     if (flavor == RpcAuthInfo.AuthFlavor.AuthNone)
     {
         credentials = new CredentialsNone();
     }
     else
     {
         if (flavor == RpcAuthInfo.AuthFlavor.AuthSys)
         {
             credentials = new CredentialsSys();
         }
         else
         {
             if (flavor == RpcAuthInfo.AuthFlavor.RpcsecGss)
             {
                 credentials = new CredentialsGSS();
             }
             else
             {
                 throw new NotSupportedException("Unsupported Credentials Flavor " + flavor);
             }
         }
     }
     credentials.Read(xdr);
     return(credentials);
 }
Example #13
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.SETATTR3Response Deserialize(XDR
                                                                                       xdr)
        {
            int     status  = xdr.ReadInt();
            WccData wccData = WccData.Deserialize(xdr);

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.SETATTR3Response(status, wccData));
        }
Example #14
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.REMOVE3Response Deserialize(XDR
                                                                                      xdr)
        {
            int     status = xdr.ReadInt();
            WccData dirWcc = WccData.Deserialize(xdr);

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.REMOVE3Response(status, dirWcc));
        }
Example #15
0
        /// <exception cref="System.IO.IOException"/>
        public static Org.Apache.Hadoop.Nfs.Nfs3.Request.READ3Request Deserialize(XDR xdr
                                                                                  )
        {
            FileHandle handle = ReadHandle(xdr);
            long       offset = xdr.ReadHyper();
            int        count  = xdr.ReadInt();

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Request.READ3Request(handle, offset, count));
        }
Example #16
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.GETATTR3Response Deserialize(XDR
                                                                                       xdr)
        {
            int status = xdr.ReadInt();
            Nfs3FileAttributes attr = (status == Nfs3Status.Nfs3Ok) ? Nfs3FileAttributes.Deserialize
                                          (xdr) : new Nfs3FileAttributes();

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.GETATTR3Response(status, attr));
        }
Example #17
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.LINK3Response Deserialize(XDR xdr
                                                                                    )
        {
            int     status     = xdr.ReadInt();
            WccData fromDirWcc = WccData.Deserialize(xdr);
            WccData linkDirWcc = WccData.Deserialize(xdr);

            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.LINK3Response(status, fromDirWcc,
                                                                         linkDirWcc));
        }
Example #18
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.WRITE3Response Deserialize(XDR
                                                                                     xdr)
        {
            int     status  = xdr.ReadInt();
            WccData fileWcc = WccData.Deserialize(xdr);
            int     count   = 0;

            Nfs3Constant.WriteStableHow stableHow = null;
            long verifier = 0;

            if (status == Nfs3Status.Nfs3Ok)
            {
                count = xdr.ReadInt();
                int how = xdr.ReadInt();
                stableHow = Nfs3Constant.WriteStableHow.Values()[how];
                verifier  = xdr.ReadHyper();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.WRITE3Response(status, fileWcc, count
                                                                          , stableHow, verifier));
        }
Example #19
0
        public virtual bool Deserialize(XDR xdr)
        {
            if (!XDR.VerifyLength(xdr, 32))
            {
                return(false);
            }
            int size = xdr.ReadInt();

            handle = xdr.ReadFixedOpaque(size);
            fileId = BytesToLong(handle);
            return(true);
        }
Example #20
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)));
        }
Example #21
0
        public static Org.Apache.Hadoop.Nfs.Nfs3.Response.COMMIT3Response Deserialize(XDR
                                                                                      xdr)
        {
            int     status  = xdr.ReadInt();
            long    verf    = 0;
            WccData fileWcc = WccData.Deserialize(xdr);

            if (status == Nfs3Status.Nfs3Ok)
            {
                verf = xdr.ReadHyper();
            }
            return(new Org.Apache.Hadoop.Nfs.Nfs3.Response.COMMIT3Response(status, fileWcc, verf
                                                                           ));
        }
Example #22
0
        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));
        }
Example #23
0
        /// <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;
        }
Example #24
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));
        }
Example #25
0
        public override void Read(XDR xdr)
        {
            mCredentialsLength = xdr.ReadInt();
            mStamp             = xdr.ReadInt();
            mHostName          = xdr.ReadString();
            mUID = xdr.ReadInt();
            mGID = xdr.ReadInt();
            int length = xdr.ReadInt();

            mAuxGIDs = new int[length];
            for (int i = 0; i < length; i++)
            {
                mAuxGIDs[i] = xdr.ReadInt();
            }
        }
Example #26
0
        public static Nfs3FileAttributes Deserialize(XDR xdr)
        {
            Nfs3FileAttributes attr = new Nfs3FileAttributes();

            attr.type   = xdr.ReadInt();
            attr.mode   = xdr.ReadInt();
            attr.nlink  = xdr.ReadInt();
            attr.uid    = xdr.ReadInt();
            attr.gid    = xdr.ReadInt();
            attr.size   = xdr.ReadHyper();
            attr.used   = xdr.ReadHyper();
            attr.rdev   = new Nfs3FileAttributes.Specdata3(xdr.ReadInt(), xdr.ReadInt());
            attr.fsid   = xdr.ReadHyper();
            attr.fileId = xdr.ReadHyper();
            attr.atime  = NfsTime.Deserialize(xdr);
            attr.mtime  = NfsTime.Deserialize(xdr);
            attr.ctime  = NfsTime.Deserialize(xdr);
            return(attr);
        }
Example #27
0
 /// <summary>Read both AuthFlavor and the verifier from the XDR</summary>
 public static Org.Apache.Hadoop.Oncrpc.Security.Verifier ReadFlavorAndVerifier(XDR
                                                                                xdr)
 {
     RpcAuthInfo.AuthFlavor flavor = RpcAuthInfo.AuthFlavor.FromValue(xdr.ReadInt());
     Org.Apache.Hadoop.Oncrpc.Security.Verifier verifer;
     if (flavor == RpcAuthInfo.AuthFlavor.AuthNone)
     {
         verifer = new VerifierNone();
     }
     else
     {
         if (flavor == RpcAuthInfo.AuthFlavor.RpcsecGss)
         {
             verifer = new VerifierGSS();
         }
         else
         {
             throw new NotSupportedException("Unsupported verifier flavor" + flavor);
         }
     }
     verifer.Read(xdr);
     return(verifer);
 }
Example #28
0
 public static Org.Apache.Hadoop.Portmap.PortmapMapping Deserialize(XDR xdr)
 {
     return(new Org.Apache.Hadoop.Portmap.PortmapMapping(xdr.ReadInt(), xdr.ReadInt(),
                                                         xdr.ReadInt(), xdr.ReadInt()));
 }
Example #29
0
        public override void Read(XDR xdr)
        {
            int length = xdr.ReadInt();

            Preconditions.CheckState(length == 0);
        }
Example #30
0
 public static Org.Apache.Hadoop.Nfs.NfsTime Deserialize(XDR xdr)
 {
     return(new Org.Apache.Hadoop.Nfs.NfsTime(xdr.ReadInt(), xdr.ReadInt()));
 }