Пример #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestHDFSRMStateStore()
        {
            HdfsConfiguration    conf      = new HdfsConfiguration();
            UserGroupInformation yarnAdmin = UserGroupInformation.CreateUserForTesting("yarn"
                                                                                       , new string[] { "admin" });
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(1).Build();

            cluster.GetFileSystem().Mkdir(new Path("/yarn"), FsPermission.ValueOf("-rwxrwxrwx"
                                                                                  ));
            cluster.GetFileSystem().SetOwner(new Path("/yarn"), "yarn", "admin");
            UserGroupInformation hdfsAdmin = UserGroupInformation.GetCurrentUser();

            RMStateStoreTestBase.StoreStateVerifier verifier = new _StoreStateVerifier_200(this
                                                                                           , hdfsAdmin, cluster);
            // Wait for things to settle
            // Wait for things to settle
            try
            {
                yarnAdmin.DoAs(new _PrivilegedExceptionAction_243(this, cluster, verifier));
            }
            finally
            {
                cluster.Shutdown();
            }
        }
Пример #2
0
        /// <exception cref="System.Exception"/>
        private void StartCluster(Configuration conf)
        {
            if (Runtime.GetProperty("hadoop.log.dir") == null)
            {
                Runtime.SetProperty("hadoop.log.dir", "target/test-dir");
            }
            conf.Set("dfs.block.access.token.enable", "false");
            conf.Set("dfs.permissions", "true");
            conf.Set("hadoop.security.authentication", "simple");
            string cp = conf.Get(YarnConfiguration.YarnApplicationClasspath, StringUtils.Join
                                     (",", YarnConfiguration.DefaultYarnCrossPlatformApplicationClasspath)) + FilePath
                        .pathSeparator + classpathDir;

            conf.Set(YarnConfiguration.YarnApplicationClasspath, cp);
            dfsCluster = new MiniDFSCluster.Builder(conf).Build();
            FileSystem fileSystem = dfsCluster.GetFileSystem();

            fileSystem.Mkdirs(new Path("/tmp"));
            fileSystem.Mkdirs(new Path("/user"));
            fileSystem.Mkdirs(new Path("/hadoop/mapred/system"));
            fileSystem.SetPermission(new Path("/tmp"), FsPermission.ValueOf("-rwxrwxrwx"));
            fileSystem.SetPermission(new Path("/user"), FsPermission.ValueOf("-rwxrwxrwx"));
            fileSystem.SetPermission(new Path("/hadoop/mapred/system"), FsPermission.ValueOf(
                                         "-rwx------"));
            FileSystem.SetDefaultUri(conf, fileSystem.GetUri());
            mrCluster = MiniMRClientClusterFactory.Create(this.GetType(), 1, conf);
            // so the minicluster conf is avail to the containers.
            TextWriter writer = new FileWriter(classpathDir + "/core-site.xml");

            mrCluster.GetConfig().WriteXml(writer);
            writer.Close();
        }
Пример #3
0
            /// loads permissions, owner, and group from `ls -ld`
            private void LoadPermissionInfo()
            {
                IOException e = null;

                try
                {
                    string output = FileUtil.ExecCommand(new FilePath(GetPath().ToUri()), Shell.GetGetPermissionCommand
                                                             ());
                    StringTokenizer t = new StringTokenizer(output, Shell.TokenSeparatorRegex);
                    //expected format
                    //-rw-------    1 username groupname ...
                    string permission = t.NextToken();
                    if (permission.Length > FsPermission.MaxPermissionLength)
                    {
                        //files with ACLs might have a '+'
                        permission = Runtime.Substring(permission, 0, FsPermission.MaxPermissionLength
                                                       );
                    }
                    SetPermission(FsPermission.ValueOf(permission));
                    t.NextToken();
                    string owner = t.NextToken();
                    // If on windows domain, token format is DOMAIN\\user and we want to
                    // extract only the user name
                    if (Shell.Windows)
                    {
                        int i = owner.IndexOf('\\');
                        if (i != -1)
                        {
                            owner = Runtime.Substring(owner, i + 1);
                        }
                    }
                    SetOwner(owner);
                    SetGroup(t.NextToken());
                }
                catch (Shell.ExitCodeException ioe)
                {
                    if (ioe.GetExitCode() != 1)
                    {
                        e = ioe;
                    }
                    else
                    {
                        SetPermission(null);
                        SetOwner(null);
                        SetGroup(null);
                    }
                }
                catch (IOException ioe)
                {
                    e = ioe;
                }
                finally
                {
                    if (e != null)
                    {
                        throw new RuntimeException("Error while running command to get " + "file permissions : "
                                                   + StringUtils.StringifyException(e));
                    }
                }
            }
Пример #4
0
        /// <summary>
        /// Test the listing with different user names to make sure only directories
        /// that are owned by the user are listed.
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestListWithDifferentUser()
        {
            cluster.GetNamesystem().GetSnapshotManager().SetAllowNestedSnapshots(true);
            // first make dir1 and dir2 snapshottable
            hdfs.AllowSnapshot(dir1);
            hdfs.AllowSnapshot(dir2);
            hdfs.SetPermission(root, FsPermission.ValueOf("-rwxrwxrwx"));
            // create two dirs and make them snapshottable under the name of user1
            UserGroupInformation ugi1 = UserGroupInformation.CreateUserForTesting("user1", new
                                                                                  string[] { "group1" });
            DistributedFileSystem fs1 = (DistributedFileSystem)DFSTestUtil.GetFileSystemAs(ugi1
                                                                                           , conf);
            Path dir1_user1 = new Path("/dir1_user1");
            Path dir2_user1 = new Path("/dir2_user1");

            fs1.Mkdirs(dir1_user1);
            fs1.Mkdirs(dir2_user1);
            hdfs.AllowSnapshot(dir1_user1);
            hdfs.AllowSnapshot(dir2_user1);
            // user2
            UserGroupInformation ugi2 = UserGroupInformation.CreateUserForTesting("user2", new
                                                                                  string[] { "group2" });
            DistributedFileSystem fs2 = (DistributedFileSystem)DFSTestUtil.GetFileSystemAs(ugi2
                                                                                           , conf);
            Path dir_user2    = new Path("/dir_user2");
            Path subdir_user2 = new Path(dir_user2, "subdir");

            fs2.Mkdirs(dir_user2);
            fs2.Mkdirs(subdir_user2);
            hdfs.AllowSnapshot(dir_user2);
            hdfs.AllowSnapshot(subdir_user2);
            // super user
            string supergroup = conf.Get(DFSConfigKeys.DfsPermissionsSuperusergroupKey, DFSConfigKeys
                                         .DfsPermissionsSuperusergroupDefault);
            UserGroupInformation superUgi = UserGroupInformation.CreateUserForTesting("superuser"
                                                                                      , new string[] { supergroup });
            DistributedFileSystem fs3 = (DistributedFileSystem)DFSTestUtil.GetFileSystemAs(superUgi
                                                                                           , conf);

            // list the snapshottable dirs for superuser
            SnapshottableDirectoryStatus[] dirs = fs3.GetSnapshottableDirListing();
            // 6 snapshottable dirs: dir1, dir2, dir1_user1, dir2_user1, dir_user2, and
            // subdir_user2
            NUnit.Framework.Assert.AreEqual(6, dirs.Length);
            // list the snapshottable dirs for user1
            dirs = fs1.GetSnapshottableDirListing();
            // 2 dirs owned by user1: dir1_user1 and dir2_user1
            NUnit.Framework.Assert.AreEqual(2, dirs.Length);
            NUnit.Framework.Assert.AreEqual(dir1_user1, dirs[0].GetFullPath());
            NUnit.Framework.Assert.AreEqual(dir2_user1, dirs[1].GetFullPath());
            // list the snapshottable dirs for user2
            dirs = fs2.GetSnapshottableDirListing();
            // 2 dirs owned by user2: dir_user2 and subdir_user2
            NUnit.Framework.Assert.AreEqual(2, dirs.Length);
            NUnit.Framework.Assert.AreEqual(dir_user2, dirs[0].GetFullPath());
            NUnit.Framework.Assert.AreEqual(subdir_user2, dirs[1].GetFullPath());
        }
Пример #5
0
        public virtual void TestEquals()
        {
            Path       path        = new Path("path");
            FileStatus fileStatus1 = new FileStatus(1, true, 1, 1, 1, 1, FsPermission.ValueOf
                                                        ("-rw-rw-rw-"), "one", "one", null, path);
            FileStatus fileStatus2 = new FileStatus(2, true, 2, 2, 2, 2, FsPermission.ValueOf
                                                        ("---x--x--x"), "two", "two", null, path);

            Assert.Equal(fileStatus1, fileStatus2);
        }
Пример #6
0
        public virtual void TestNotEquals()
        {
            Path       path1       = new Path("path1");
            Path       path2       = new Path("path2");
            FileStatus fileStatus1 = new FileStatus(1, true, 1, 1, 1, 1, FsPermission.ValueOf
                                                        ("-rw-rw-rw-"), "one", "one", null, path1);
            FileStatus fileStatus2 = new FileStatus(1, true, 1, 1, 1, 1, FsPermission.ValueOf
                                                        ("-rw-rw-rw-"), "one", "one", null, path2);

            NUnit.Framework.Assert.IsFalse(fileStatus1.Equals(fileStatus2));
            NUnit.Framework.Assert.IsFalse(fileStatus2.Equals(fileStatus1));
        }
Пример #7
0
        /// <exception cref="System.Exception"/>
        protected override void SetUp()
        {
            base.SetUp();
            if (Runtime.GetProperty("hadoop.log.dir") == null)
            {
                Runtime.SetProperty("hadoop.log.dir", "/tmp");
            }
            int           taskTrackers = 2;
            int           dataNodes    = 2;
            string        proxyUser    = Runtime.GetProperty("user.name");
            string        proxyGroup   = "g";
            StringBuilder sb           = new StringBuilder();

            sb.Append("127.0.0.1,localhost");
            foreach (IPAddress i in IPAddress.GetAllByName(Sharpen.Runtime.GetLocalHost().GetHostName
                                                               ()))
            {
                sb.Append(",").Append(i.ToString());
            }
            JobConf conf = new JobConf();

            conf.Set("dfs.block.access.token.enable", "false");
            conf.Set("dfs.permissions", "true");
            conf.Set("hadoop.security.authentication", "simple");
            conf.Set("hadoop.proxyuser." + proxyUser + ".hosts", sb.ToString());
            conf.Set("hadoop.proxyuser." + proxyUser + ".groups", proxyGroup);
            string[] userGroups = new string[] { proxyGroup };
            UserGroupInformation.CreateUserForTesting(proxyUser, userGroups);
            UserGroupInformation.CreateUserForTesting("u1", userGroups);
            UserGroupInformation.CreateUserForTesting("u2", new string[] { "gg" });
            dfsCluster = new MiniDFSCluster.Builder(conf).NumDataNodes(dataNodes).Build();
            FileSystem fileSystem = dfsCluster.GetFileSystem();

            fileSystem.Mkdirs(new Path("/tmp"));
            fileSystem.Mkdirs(new Path("/user"));
            fileSystem.Mkdirs(new Path("/hadoop/mapred/system"));
            fileSystem.SetPermission(new Path("/tmp"), FsPermission.ValueOf("-rwxrwxrwx"));
            fileSystem.SetPermission(new Path("/user"), FsPermission.ValueOf("-rwxrwxrwx"));
            fileSystem.SetPermission(new Path("/hadoop/mapred/system"), FsPermission.ValueOf(
                                         "-rwx------"));
            string nnURI   = fileSystem.GetUri().ToString();
            int    numDirs = 1;

            string[] racks = null;
            string[] hosts = null;
            mrCluster = new MiniMRCluster(0, 0, taskTrackers, nnURI, numDirs, racks, hosts, null
                                          , conf);
            ProxyUsers.RefreshSuperUserGroupsConfiguration(conf);
        }
Пример #8
0
 /// <exception cref="System.IO.IOException"/>
 public override void Flush()
 {
     base.Flush();
     if (!Shell.Windows)
     {
         Files.SetPosixFilePermissions(Paths.Get(file.GetCanonicalPath()), permissions);
     }
     else
     {
         // FsPermission expects a 10-character string because of the leading
         // directory indicator, i.e. "drwx------". The JDK toString method returns
         // a 9-character string, so prepend a leading character.
         FsPermission fsPermission = FsPermission.ValueOf("-" + PosixFilePermissions.ToString
                                                              (permissions));
         FileUtil.SetPermission(file, fsPermission);
     }
 }
Пример #9
0
            /// <exception cref="Org.Xml.Sax.SAXException"/>
            public override void StartElement(string ns, string localname, string qname, Attributes
                                              attrs)
            {
                if ("listing".Equals(qname))
                {
                    return;
                }
                if (!"file".Equals(qname) && !"directory".Equals(qname))
                {
                    if (typeof(RemoteException).Name.Equals(qname))
                    {
                        throw new SAXException(RemoteException.ValueOf(attrs));
                    }
                    throw new SAXException("Unrecognized entry: " + qname);
                }
                long modif;
                long atime = 0;

                try
                {
                    SimpleDateFormat ldf = HftpFileSystem.df.Get();
                    modif = ldf.Parse(attrs.GetValue("modified")).GetTime();
                    string astr = attrs.GetValue("accesstime");
                    if (astr != null)
                    {
                        atime = ldf.Parse(astr).GetTime();
                    }
                }
                catch (ParseException e)
                {
                    throw new SAXException(e);
                }
                FileStatus fs = "file".Equals(qname) ? new FileStatus(long.Parse(attrs.GetValue("size"
                                                                                                )), false, short.ValueOf(attrs.GetValue("replication")), long.Parse(attrs.GetValue
                                                                                                                                                                        ("blocksize")), modif, atime, FsPermission.ValueOf(attrs.GetValue("permission"))
                                                                      , attrs.GetValue("owner"), attrs.GetValue("group"), this._enclosing.MakeQualified
                                                                          (new Path(this._enclosing.GetUri().ToString(), attrs.GetValue("path")))) : new FileStatus
                                    (0L, true, 0, 0L, modif, atime, FsPermission.ValueOf(attrs.GetValue("permission"
                                                                                                        )), attrs.GetValue("owner"), attrs.GetValue("group"), this._enclosing.MakeQualified
                                        (new Path(this._enclosing.GetUri().ToString(), attrs.GetValue("path"))));

                this.fslist.AddItem(fs);
            }
Пример #10
0
 /// <exception cref="System.Exception"/>
 private static MiniDFSCluster StartMiniHdfs(Configuration conf)
 {
     lock (typeof(TestHdfsHelper))
     {
         if (MiniDfs == null)
         {
             if (Runtime.GetProperty("hadoop.log.dir") == null)
             {
                 Runtime.SetProperty("hadoop.log.dir", new FilePath(TestDirRoot, "hadoop-log").GetAbsolutePath
                                         ());
             }
             if (Runtime.GetProperty("test.build.data") == null)
             {
                 Runtime.SetProperty("test.build.data", new FilePath(TestDirRoot, "hadoop-data").GetAbsolutePath
                                         ());
             }
             conf = new Configuration(conf);
             HadoopUsersConfTestHelper.AddUserConf(conf);
             conf.Set("fs.hdfs.impl.disable.cache", "true");
             conf.Set("dfs.block.access.token.enable", "false");
             conf.Set("dfs.permissions", "true");
             conf.Set("hadoop.security.authentication", "simple");
             conf.SetBoolean(DFSConfigKeys.DfsNamenodeAclsEnabledKey, true);
             conf.SetBoolean(DFSConfigKeys.DfsNamenodeXattrsEnabledKey, true);
             MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
             builder.NumDataNodes(2);
             MiniDFSCluster miniHdfs   = builder.Build();
             FileSystem     fileSystem = miniHdfs.GetFileSystem();
             fileSystem.Mkdirs(new Path("/tmp"));
             fileSystem.Mkdirs(new Path("/user"));
             fileSystem.SetPermission(new Path("/tmp"), FsPermission.ValueOf("-rwxrwxrwx"));
             fileSystem.SetPermission(new Path("/user"), FsPermission.ValueOf("-rwxrwxrwx"));
             MiniDfs = miniHdfs;
         }
         return(MiniDfs);
     }
 }
        /// <summary>Tests all FsEditLogOps that are converted to inotify events.</summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Sharpen.URISyntaxException"/>
        /// <exception cref="System.Exception"/>
        /// <exception cref="Org.Apache.Hadoop.Hdfs.Inotify.MissingEventsException"/>
        public virtual void TestBasic()
        {
            Configuration conf = new HdfsConfiguration();

            conf.SetLong(DFSConfigKeys.DfsBlockSizeKey, BlockSize);
            conf.SetBoolean(DFSConfigKeys.DfsNamenodeAclsEnabledKey, true);
            // so that we can get an atime change
            conf.SetLong(DFSConfigKeys.DfsNamenodeAccesstimePrecisionKey, 1);
            MiniQJMHACluster.Builder builder = new MiniQJMHACluster.Builder(conf);
            builder.GetDfsBuilder().NumDataNodes(2);
            MiniQJMHACluster cluster = builder.Build();

            try
            {
                cluster.GetDfsCluster().WaitActive();
                cluster.GetDfsCluster().TransitionToActive(0);
                DFSClient client = new DFSClient(cluster.GetDfsCluster().GetNameNode(0).GetNameNodeAddress
                                                     (), conf);
                FileSystem fs = cluster.GetDfsCluster().GetFileSystem(0);
                DFSTestUtil.CreateFile(fs, new Path("/file"), BlockSize, (short)1, 0L);
                DFSTestUtil.CreateFile(fs, new Path("/file3"), BlockSize, (short)1, 0L);
                DFSTestUtil.CreateFile(fs, new Path("/file5"), BlockSize, (short)1, 0L);
                DFSInotifyEventInputStream eis = client.GetInotifyEventStream();
                client.Rename("/file", "/file4", null);
                // RenameOp -> RenameEvent
                client.Rename("/file4", "/file2");
                // RenameOldOp -> RenameEvent
                // DeleteOp, AddOp -> UnlinkEvent, CreateEvent
                OutputStream os = client.Create("/file2", true, (short)2, BlockSize);
                os.Write(new byte[BlockSize]);
                os.Close();
                // CloseOp -> CloseEvent
                // AddOp -> AppendEvent
                os = client.Append("/file2", BlockSize, EnumSet.Of(CreateFlag.Append), null, null
                                   );
                os.Write(new byte[BlockSize]);
                os.Close();
                // CloseOp -> CloseEvent
                Sharpen.Thread.Sleep(10);
                // so that the atime will get updated on the next line
                client.Open("/file2").Read(new byte[1]);
                // TimesOp -> MetadataUpdateEvent
                // SetReplicationOp -> MetadataUpdateEvent
                client.SetReplication("/file2", (short)1);
                // ConcatDeleteOp -> AppendEvent, UnlinkEvent, CloseEvent
                client.Concat("/file2", new string[] { "/file3" });
                client.Delete("/file2", false);
                // DeleteOp -> UnlinkEvent
                client.Mkdirs("/dir", null, false);
                // MkdirOp -> CreateEvent
                // SetPermissionsOp -> MetadataUpdateEvent
                client.SetPermission("/dir", FsPermission.ValueOf("-rw-rw-rw-"));
                // SetOwnerOp -> MetadataUpdateEvent
                client.SetOwner("/dir", "username", "groupname");
                client.CreateSymlink("/dir", "/dir2", false);
                // SymlinkOp -> CreateEvent
                client.SetXAttr("/file5", "user.field", Sharpen.Runtime.GetBytesForString("value"
                                                                                          ), EnumSet.Of(XAttrSetFlag.Create));
                // SetXAttrOp -> MetadataUpdateEvent
                // RemoveXAttrOp -> MetadataUpdateEvent
                client.RemoveXAttr("/file5", "user.field");
                // SetAclOp -> MetadataUpdateEvent
                client.SetAcl("/file5", AclEntry.ParseAclSpec("user::rwx,user:foo:rw-,group::r--,other::---"
                                                              , true));
                client.RemoveAcl("/file5");
                // SetAclOp -> MetadataUpdateEvent
                client.Rename("/file5", "/dir");
                // RenameOldOp -> RenameEvent
                EventBatch batch = null;
                // RenameOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                long txid = batch.GetTxid();
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Rename);
                Event.RenameEvent re = (Event.RenameEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.AreEqual("/file4", re.GetDstPath());
                NUnit.Framework.Assert.AreEqual("/file", re.GetSrcPath());
                NUnit.Framework.Assert.IsTrue(re.GetTimestamp() > 0);
                long eventsBehind = eis.GetTxidsBehindEstimate();
                // RenameOldOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Rename);
                Event.RenameEvent re2 = (Event.RenameEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(re2.GetDstPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(re2.GetSrcPath().Equals("/file4"));
                NUnit.Framework.Assert.IsTrue(re.GetTimestamp() > 0);
                // AddOp with overwrite
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Create);
                Event.CreateEvent ce = (Event.CreateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(ce.GetiNodeType() == Event.CreateEvent.INodeType.File
                                              );
                NUnit.Framework.Assert.IsTrue(ce.GetPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(ce.GetCtime() > 0);
                NUnit.Framework.Assert.IsTrue(ce.GetReplication() > 0);
                NUnit.Framework.Assert.IsTrue(ce.GetSymlinkTarget() == null);
                NUnit.Framework.Assert.IsTrue(ce.GetOverwrite());
                NUnit.Framework.Assert.AreEqual(BlockSize, ce.GetDefaultBlockSize());
                // CloseOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Close);
                Event.CloseEvent ce2 = (Event.CloseEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(ce2.GetPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(ce2.GetFileSize() > 0);
                NUnit.Framework.Assert.IsTrue(ce2.GetTimestamp() > 0);
                // AppendOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Append);
                Event.AppendEvent append2 = (Event.AppendEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.AreEqual("/file2", append2.GetPath());
                NUnit.Framework.Assert.IsFalse(append2.ToNewBlock());
                // CloseOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Close);
                NUnit.Framework.Assert.IsTrue(((Event.CloseEvent)batch.GetEvents()[0]).GetPath().
                                              Equals("/file2"));
                // TimesOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue.GetPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(mue.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Times);
                // SetReplicationOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue2 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue2.GetPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(mue2.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Replication);
                NUnit.Framework.Assert.IsTrue(mue2.GetReplication() == 1);
                // ConcatDeleteOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(3, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Append);
                NUnit.Framework.Assert.IsTrue(((Event.AppendEvent)batch.GetEvents()[0]).GetPath()
                                              .Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[1].GetEventType() == Event.EventType
                                              .Unlink);
                Event.UnlinkEvent ue2 = (Event.UnlinkEvent)batch.GetEvents()[1];
                NUnit.Framework.Assert.IsTrue(ue2.GetPath().Equals("/file3"));
                NUnit.Framework.Assert.IsTrue(ue2.GetTimestamp() > 0);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[2].GetEventType() == Event.EventType
                                              .Close);
                Event.CloseEvent ce3 = (Event.CloseEvent)batch.GetEvents()[2];
                NUnit.Framework.Assert.IsTrue(ce3.GetPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(ce3.GetTimestamp() > 0);
                // DeleteOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Unlink);
                Event.UnlinkEvent ue = (Event.UnlinkEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(ue.GetPath().Equals("/file2"));
                NUnit.Framework.Assert.IsTrue(ue.GetTimestamp() > 0);
                // MkdirOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Create);
                Event.CreateEvent ce4 = (Event.CreateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(ce4.GetiNodeType() == Event.CreateEvent.INodeType.Directory
                                              );
                NUnit.Framework.Assert.IsTrue(ce4.GetPath().Equals("/dir"));
                NUnit.Framework.Assert.IsTrue(ce4.GetCtime() > 0);
                NUnit.Framework.Assert.IsTrue(ce4.GetReplication() == 0);
                NUnit.Framework.Assert.IsTrue(ce4.GetSymlinkTarget() == null);
                // SetPermissionsOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue3 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue3.GetPath().Equals("/dir"));
                NUnit.Framework.Assert.IsTrue(mue3.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Perms);
                NUnit.Framework.Assert.IsTrue(mue3.GetPerms().ToString().Contains("rw-rw-rw-"));
                // SetOwnerOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue4 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue4.GetPath().Equals("/dir"));
                NUnit.Framework.Assert.IsTrue(mue4.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Owner);
                NUnit.Framework.Assert.IsTrue(mue4.GetOwnerName().Equals("username"));
                NUnit.Framework.Assert.IsTrue(mue4.GetGroupName().Equals("groupname"));
                // SymlinkOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Create);
                Event.CreateEvent ce5 = (Event.CreateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(ce5.GetiNodeType() == Event.CreateEvent.INodeType.Symlink
                                              );
                NUnit.Framework.Assert.IsTrue(ce5.GetPath().Equals("/dir2"));
                NUnit.Framework.Assert.IsTrue(ce5.GetCtime() > 0);
                NUnit.Framework.Assert.IsTrue(ce5.GetReplication() == 0);
                NUnit.Framework.Assert.IsTrue(ce5.GetSymlinkTarget().Equals("/dir"));
                // SetXAttrOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue5 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue5.GetPath().Equals("/file5"));
                NUnit.Framework.Assert.IsTrue(mue5.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Xattrs);
                NUnit.Framework.Assert.IsTrue(mue5.GetxAttrs().Count == 1);
                NUnit.Framework.Assert.IsTrue(mue5.GetxAttrs()[0].GetName().Contains("field"));
                NUnit.Framework.Assert.IsTrue(!mue5.IsxAttrsRemoved());
                // RemoveXAttrOp
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue6 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue6.GetPath().Equals("/file5"));
                NUnit.Framework.Assert.IsTrue(mue6.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Xattrs);
                NUnit.Framework.Assert.IsTrue(mue6.GetxAttrs().Count == 1);
                NUnit.Framework.Assert.IsTrue(mue6.GetxAttrs()[0].GetName().Contains("field"));
                NUnit.Framework.Assert.IsTrue(mue6.IsxAttrsRemoved());
                // SetAclOp (1)
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue7 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue7.GetPath().Equals("/file5"));
                NUnit.Framework.Assert.IsTrue(mue7.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Acls);
                NUnit.Framework.Assert.IsTrue(mue7.GetAcls().Contains(AclEntry.ParseAclEntry("user::rwx"
                                                                                             , true)));
                // SetAclOp (2)
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Metadata);
                Event.MetadataUpdateEvent mue8 = (Event.MetadataUpdateEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(mue8.GetPath().Equals("/file5"));
                NUnit.Framework.Assert.IsTrue(mue8.GetMetadataType() == Event.MetadataUpdateEvent.MetadataType
                                              .Acls);
                NUnit.Framework.Assert.IsTrue(mue8.GetAcls() == null);
                // RenameOp (2)
                batch = WaitForNextEvents(eis);
                NUnit.Framework.Assert.AreEqual(1, batch.GetEvents().Length);
                txid = CheckTxid(batch, txid);
                NUnit.Framework.Assert.IsTrue(batch.GetEvents()[0].GetEventType() == Event.EventType
                                              .Rename);
                Event.RenameEvent re3 = (Event.RenameEvent)batch.GetEvents()[0];
                NUnit.Framework.Assert.IsTrue(re3.GetDstPath().Equals("/dir/file5"));
                NUnit.Framework.Assert.IsTrue(re3.GetSrcPath().Equals("/file5"));
                NUnit.Framework.Assert.IsTrue(re.GetTimestamp() > 0);
                // Returns null when there are no further events
                NUnit.Framework.Assert.IsTrue(eis.Poll() == null);
                // make sure the estimate hasn't changed since the above assertion
                // tells us that we are fully caught up to the current namesystem state
                // and we should not have been behind at all when eventsBehind was set
                // either, since there were few enough events that they should have all
                // been read to the client during the first poll() call
                NUnit.Framework.Assert.IsTrue(eis.GetTxidsBehindEstimate() == eventsBehind);
            }
            finally
            {
                cluster.Shutdown();
            }
        }