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)); }
public READLINK3Response(int status, Nfs3FileAttributes postOpAttr, byte[] path) : base(status) { this.postOpSymlinkAttr = postOpAttr; this.path = new byte[path.Length]; System.Array.Copy(path, 0, this.path, 0, path.Length); }
public PATHCONF3Response(int status, Nfs3FileAttributes postOpAttr, int linkMax, int nameMax, bool noTrunc, bool chownRestricted, bool caseInsensitive, bool casePreserving ) : base(status) { /* The maximum number of hard links to an object. */ /* The maximum length of a component of a filename. */ /* * If TRUE, the server will reject any request that includes a name longer * than name_max with the error, NFS3ERR_NAMETOOLONG. If FALSE, any length * name over name_max bytes will be silently truncated to name_max bytes. */ /* * If TRUE, the server will reject any request to change either the owner or * the group associated with a file if the caller is not the privileged user. * (Uid 0.) */ /* * If TRUE, the server file system does not distinguish case when interpreting * filenames. */ /* * If TRUE, the server file system will preserve the case of a name during a * CREATE, MKDIR, MKNOD, SYMLINK, RENAME, or LINK operation. */ this.postOpAttr = postOpAttr; this.linkMax = linkMax; this.nameMax = nameMax; this.noTrunc = noTrunc; this.chownRestricted = chownRestricted; this.caseInsensitive = caseInsensitive; this.casePreserving = casePreserving; }
public virtual void TestCheckCommitAixCompatMode() { DFSClient dfsClient = Org.Mockito.Mockito.Mock <DFSClient>(); Nfs3FileAttributes attr = new Nfs3FileAttributes(); HdfsDataOutputStream fos = Org.Mockito.Mockito.Mock <HdfsDataOutputStream>(); NfsConfiguration conf = new NfsConfiguration(); conf.SetBoolean(NfsConfigKeys.LargeFileUpload, false); // Enable AIX compatibility mode. OpenFileCtx ctx = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping (new NfsConfiguration()), true, conf); // Test fall-through to pendingWrites check in the event that commitOffset // is greater than the number of bytes we've so far flushed. Org.Mockito.Mockito.When(fos.GetPos()).ThenReturn((long)2); OpenFileCtx.COMMIT_STATUS status = ctx.CheckCommitInternal(5, null, 1, attr, false ); NUnit.Framework.Assert.IsTrue(status == OpenFileCtx.COMMIT_STATUS.CommitFinished); // Test the case when we actually have received more bytes than we're trying // to commit. ctx.GetPendingWritesForTest()[new OffsetRange(0, 10)] = new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null); Org.Mockito.Mockito.When(fos.GetPos()).ThenReturn((long)10); ctx.SetNextOffsetForTest((long)10); status = ctx.CheckCommitInternal(5, null, 1, attr, false); NUnit.Framework.Assert.IsTrue(status == OpenFileCtx.COMMIT_STATUS.CommitDoSync); }
public static READDIRPLUS3Response Deserialize(XDR xdr) { int status = xdr.ReadInt(); xdr.ReadBoolean(); Nfs3FileAttributes postOpDirAttr = Nfs3FileAttributes.Deserialize(xdr); long cookieVerf = 0; AList <READDIRPLUS3Response.EntryPlus3> entries = new AList <READDIRPLUS3Response.EntryPlus3 >(); READDIRPLUS3Response.DirListPlus3 dirList = null; if (status == Nfs3Status.Nfs3Ok) { cookieVerf = xdr.ReadHyper(); while (xdr.ReadBoolean()) { READDIRPLUS3Response.EntryPlus3 e = READDIRPLUS3Response.EntryPlus3.Deseralize(xdr ); entries.AddItem(e); } bool eof = xdr.ReadBoolean(); READDIRPLUS3Response.EntryPlus3[] allEntries = new READDIRPLUS3Response.EntryPlus3 [entries.Count]; Collections.ToArray(entries, allEntries); dirList = new READDIRPLUS3Response.DirListPlus3(allEntries, eof); } return(new READDIRPLUS3Response(status, postOpDirAttr, cookieVerf, dirList)); }
public void RoundTripTest() { Nfs3FileAttributes attributes = new Nfs3FileAttributes() { AccessTime = new Nfs3FileTime(new DateTime(2018, 1, 1)), BytesUsed = 1, ChangeTime = new Nfs3FileTime(new DateTime(2018, 1, 2)), FileId = 3, FileSystemId = 4, Gid = 5, LinkCount = 6, Mode = UnixFilePermissions.GroupExecute, ModifyTime = new Nfs3FileTime(new DateTime(2018, 1, 3)), RdevMajor = 7, RdevMinor = 8, Size = 9, Type = Nfs3FileType.NamedPipe, Uid = 11 }; Nfs3FileAttributes clone = null; using (MemoryStream stream = new MemoryStream()) { XdrDataWriter writer = new XdrDataWriter(stream); attributes.Write(writer); stream.Position = 0; XdrDataReader reader = new XdrDataReader(stream); clone = new Nfs3FileAttributes(reader); } Assert.Equal(attributes, clone); }
public virtual void TestCheckSequential() { DFSClient dfsClient = Org.Mockito.Mockito.Mock <DFSClient>(); Nfs3FileAttributes attr = new Nfs3FileAttributes(); HdfsDataOutputStream fos = Org.Mockito.Mockito.Mock <HdfsDataOutputStream>(); Org.Mockito.Mockito.When(fos.GetPos()).ThenReturn((long)0); NfsConfiguration config = new NfsConfiguration(); config.SetBoolean(NfsConfigKeys.LargeFileUpload, false); OpenFileCtx ctx = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping (config), false, config); ctx.GetPendingWritesForTest()[new OffsetRange(5, 10)] = new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null); ctx.GetPendingWritesForTest()[new OffsetRange(10, 15)] = new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null); ctx.GetPendingWritesForTest()[new OffsetRange(20, 25)] = new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null); NUnit.Framework.Assert.IsTrue(!ctx.CheckSequential(5, 4)); NUnit.Framework.Assert.IsTrue(ctx.CheckSequential(9, 5)); NUnit.Framework.Assert.IsTrue(ctx.CheckSequential(10, 5)); NUnit.Framework.Assert.IsTrue(ctx.CheckSequential(14, 5)); NUnit.Framework.Assert.IsTrue(!ctx.CheckSequential(15, 5)); NUnit.Framework.Assert.IsTrue(!ctx.CheckSequential(20, 5)); NUnit.Framework.Assert.IsTrue(!ctx.CheckSequential(25, 5)); NUnit.Framework.Assert.IsTrue(!ctx.CheckSequential(999, 5)); }
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)); }
public MKNOD3Response(int status, FileHandle handle, Nfs3FileAttributes attrs, WccData dirWcc) : base(status) { this.objFileHandle = handle; this.objPostOpAttr = attrs; this.dirWcc = dirWcc; }
public READDIRPLUS3Response(int status, Nfs3FileAttributes postOpDirAttr, long cookieVerf , READDIRPLUS3Response.DirListPlus3 dirListPlus) : base(status) { this.postOpDirAttr = postOpDirAttr; this.cookieVerf = cookieVerf; this.dirListPlus = dirListPlus; }
public CREATE3Response(int status, FileHandle handle, Nfs3FileAttributes postOpObjAttr , WccData dirWcc) : base(status) { this.objHandle = handle; this.postOpObjAttr = postOpObjAttr; this.dirWcc = dirWcc; }
public MKDIR3Response(int status, FileHandle handle, Nfs3FileAttributes attr, WccData dirWcc) : base(status) { this.objFileHandle = handle; this.objAttr = attr; this.dirWcc = dirWcc; }
public READDIR3Response(int status, Nfs3FileAttributes postOpAttr, long cookieVerf , READDIR3Response.DirList3 dirList) : base(status) { this.postOpDirAttr = postOpAttr; this.cookieVerf = cookieVerf; this.dirList = dirList; }
public EntryPlus3(long fileId, string name, long cookie, Nfs3FileAttributes nameAttr , FileHandle objFileHandle) { this.fileId = fileId; this.name = name; this.cookie = cookie; this.nameAttr = nameAttr; this.objFileHandle = objFileHandle; }
public Nfs3AccessResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); if (reader.ReadBool()) { ObjectAttributes = new Nfs3FileAttributes(reader); } Access = (Nfs3AccessPermissions)reader.ReadInt32(); }
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)); }
public virtual void TestGetAccessRightsForUserGroup() { Nfs3FileAttributes attr = Org.Mockito.Mockito.Mock <Nfs3FileAttributes>(); Org.Mockito.Mockito.When(attr.GetUid()).ThenReturn(2); Org.Mockito.Mockito.When(attr.GetGid()).ThenReturn(3); Org.Mockito.Mockito.When(attr.GetMode()).ThenReturn(448); // 700 Org.Mockito.Mockito.When(attr.GetType()).ThenReturn(NfsFileType.Nfsreg.ToValue()); NUnit.Framework.Assert.AreEqual("No access should be allowed as UID does not match attribute over mode 700" , 0, Nfs3Utils.GetAccessRightsForUserGroup(3, 3, null, attr)); Org.Mockito.Mockito.When(attr.GetUid()).ThenReturn(2); Org.Mockito.Mockito.When(attr.GetGid()).ThenReturn(3); Org.Mockito.Mockito.When(attr.GetMode()).ThenReturn(56); // 070 Org.Mockito.Mockito.When(attr.GetType()).ThenReturn(NfsFileType.Nfsreg.ToValue()); NUnit.Framework.Assert.AreEqual("No access should be allowed as GID does not match attribute over mode 070" , 0, Nfs3Utils.GetAccessRightsForUserGroup(2, 4, null, attr)); Org.Mockito.Mockito.When(attr.GetUid()).ThenReturn(2); Org.Mockito.Mockito.When(attr.GetGid()).ThenReturn(3); Org.Mockito.Mockito.When(attr.GetMode()).ThenReturn(7); // 007 Org.Mockito.Mockito.When(attr.GetType()).ThenReturn(NfsFileType.Nfsreg.ToValue()); NUnit.Framework.Assert.AreEqual("Access should be allowed as mode is 007 and UID/GID do not match" , 61, Nfs3Utils.GetAccessRightsForUserGroup(1, 4, new int[] { 5, 6 }, attr)); /* RWX */ Org.Mockito.Mockito.When(attr.GetUid()).ThenReturn(2); Org.Mockito.Mockito.When(attr.GetGid()).ThenReturn(10); Org.Mockito.Mockito.When(attr.GetMode()).ThenReturn(288); // 440 Org.Mockito.Mockito.When(attr.GetType()).ThenReturn(NfsFileType.Nfsreg.ToValue()); NUnit.Framework.Assert.AreEqual("Access should be allowed as mode is 440 and Aux GID does match" , 1, Nfs3Utils.GetAccessRightsForUserGroup(3, 4, new int[] { 5, 16, 10 }, attr)); /* R */ Org.Mockito.Mockito.When(attr.GetUid()).ThenReturn(2); Org.Mockito.Mockito.When(attr.GetGid()).ThenReturn(10); Org.Mockito.Mockito.When(attr.GetMode()).ThenReturn(448); // 700 Org.Mockito.Mockito.When(attr.GetType()).ThenReturn(NfsFileType.Nfsdir.ToValue()); NUnit.Framework.Assert.AreEqual("Access should be allowed for dir as mode is 700 and UID does match" , 31, Nfs3Utils.GetAccessRightsForUserGroup(2, 4, new int[] { 5, 16, 10 }, attr) ); /* Lookup */ NUnit.Framework.Assert.AreEqual("No access should be allowed for dir as mode is 700 even though GID does match" , 0, Nfs3Utils.GetAccessRightsForUserGroup(3, 10, new int[] { 5, 16, 4 }, attr)); NUnit.Framework.Assert.AreEqual("No access should be allowed for dir as mode is 700 even though AuxGID does match" , 0, Nfs3Utils.GetAccessRightsForUserGroup(3, 20, new int[] { 5, 10 }, attr)); Org.Mockito.Mockito.When(attr.GetUid()).ThenReturn(2); Org.Mockito.Mockito.When(attr.GetGid()).ThenReturn(10); Org.Mockito.Mockito.When(attr.GetMode()).ThenReturn(457); // 711 Org.Mockito.Mockito.When(attr.GetType()).ThenReturn(NfsFileType.Nfsdir.ToValue()); NUnit.Framework.Assert.AreEqual("Access should be allowed for dir as mode is 711 and GID matches" , 2, Nfs3Utils.GetAccessRightsForUserGroup(3, 10, new int[] { 5, 16, 11 }, attr) ); }
public LOOKUP3Response(int status, FileHandle fileHandle, Nfs3FileAttributes postOpObjAttr , Nfs3FileAttributes postOpDirAttributes) : base(status) { // Can be null // Can be null this.fileHandle = fileHandle; this.postOpObjAttr = postOpObjAttr; this.postOpDirAttr = postOpDirAttributes; }
public ACCESS3Response(int status, Nfs3FileAttributes postOpAttr, int access) : base(status) { /* * A bit mask of access permissions indicating access rights for the * authentication credentials provided with the request. */ this.postOpAttr = postOpAttr; this.access = access; }
public READ3Response(int status, Nfs3FileAttributes postOpAttr, int count, bool eof , ByteBuffer data) : base(status) { // The real bytes of read data this.postOpAttr = postOpAttr; this.count = count; this.eof = eof; this.data = data; }
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)); }
public Nfs3WeakCacheConsistency(XdrDataReader reader) { if (reader.ReadBool()) { Before = new Nfs3WeakCacheConsistencyAttr(reader); } if (reader.ReadBool()) { After = new Nfs3FileAttributes(reader); } }
public Nfs3FileSystemInfoResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); if (reader.ReadBool()) { PostOpAttributes = new Nfs3FileAttributes(reader); } if (Status == Nfs3Status.Ok) { FileSystemInfo = new Nfs3FileSystemInfo(reader); } }
public virtual void TestEviction() { NfsConfiguration conf = new NfsConfiguration(); // Only two entries will be in the cache conf.SetInt(NfsConfigKeys.DfsNfsMaxOpenFilesKey, 2); DFSClient dfsClient = Org.Mockito.Mockito.Mock <DFSClient>(); Nfs3FileAttributes attr = new Nfs3FileAttributes(); HdfsDataOutputStream fos = Org.Mockito.Mockito.Mock <HdfsDataOutputStream>(); Org.Mockito.Mockito.When(fos.GetPos()).ThenReturn((long)0); OpenFileCtx context1 = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping(new NfsConfiguration())); OpenFileCtx context2 = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping(new NfsConfiguration())); OpenFileCtx context3 = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping(new NfsConfiguration())); OpenFileCtx context4 = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping(new NfsConfiguration())); OpenFileCtx context5 = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient, new ShellBasedIdMapping(new NfsConfiguration())); OpenFileCtxCache cache = new OpenFileCtxCache(conf, 10 * 60 * 100); bool ret = cache.Put(new FileHandle(1), context1); NUnit.Framework.Assert.IsTrue(ret); Sharpen.Thread.Sleep(1000); ret = cache.Put(new FileHandle(2), context2); NUnit.Framework.Assert.IsTrue(ret); ret = cache.Put(new FileHandle(3), context3); NUnit.Framework.Assert.IsFalse(ret); NUnit.Framework.Assert.IsTrue(cache.Size() == 2); // Wait for the oldest stream to be evict-able, insert again Sharpen.Thread.Sleep(NfsConfigKeys.DfsNfsStreamTimeoutMinDefault); NUnit.Framework.Assert.IsTrue(cache.Size() == 2); ret = cache.Put(new FileHandle(3), context3); NUnit.Framework.Assert.IsTrue(ret); NUnit.Framework.Assert.IsTrue(cache.Size() == 2); NUnit.Framework.Assert.IsTrue(cache.Get(new FileHandle(1)) == null); // Test inactive entry is evicted immediately context3.SetActiveStatusForTest(false); ret = cache.Put(new FileHandle(4), context4); NUnit.Framework.Assert.IsTrue(ret); // Now the cache has context2 and context4 // Test eviction failure if all entries have pending work. context2.GetPendingWritesForTest()[new OffsetRange(0, 100)] = new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null); context4.GetPendingCommitsForTest()[System.Convert.ToInt64(100)] = new OpenFileCtx.CommitCtx (0, null, 0, attr); Sharpen.Thread.Sleep(NfsConfigKeys.DfsNfsStreamTimeoutMinDefault); ret = cache.Put(new FileHandle(5), context5); NUnit.Framework.Assert.IsFalse(ret); }
public Nfs3ReadResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); if (reader.ReadBool()) { FileAttributes = new Nfs3FileAttributes(reader); } if (Status == Nfs3Status.Ok) { Count = reader.ReadInt32(); Eof = reader.ReadBool(); Data = reader.ReadBuffer(); } }
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 Nfs3DirectoryEntry(XdrDataReader reader) { FileId = reader.ReadUInt64(); Name = reader.ReadString(); Cookie = reader.ReadUInt64(); if (reader.ReadBool()) { FileAttributes = new Nfs3FileAttributes(reader); } if (reader.ReadBool()) { FileHandle = new Nfs3FileHandle(reader); } }
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)); }
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)); }
public Nfs3LookupResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); if (Status == Nfs3Status.Ok) { ObjectHandle = new Nfs3FileHandle(reader); if (reader.ReadBool()) { ObjectAttributes = new Nfs3FileAttributes(reader); } } if (reader.ReadBool()) { DirAttributes = new Nfs3FileAttributes(reader); } }
public Nfs3CreateResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); if (Status == Nfs3Status.Ok) { if (reader.ReadBool()) { FileHandle = new Nfs3FileHandle(reader); } if (reader.ReadBool()) { FileAttributes = new Nfs3FileAttributes(reader); } } CacheConsistency = new Nfs3WeakCacheConsistency(reader); }
public Nfs3ReadDirPlusResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); if (reader.ReadBool()) { DirAttributes = new Nfs3FileAttributes(reader); } if (Status == Nfs3Status.Ok) { CookieVerifier = reader.ReadBytes(Nfs3.CookieVerifierSize); DirEntries = new List<Nfs3DirectoryEntry>(); while (reader.ReadBool()) { Nfs3DirectoryEntry dirEntry = new Nfs3DirectoryEntry(reader); DirEntries.Add(dirEntry); } Eof = reader.ReadBool(); } }
public Nfs3GetAttributesResult(XdrDataReader reader) { Status = (Nfs3Status)reader.ReadInt32(); Attributes = new Nfs3FileAttributes(reader); }