コード例 #1
0
 /// <exception cref="System.IO.IOException"/>
 public Nfs3(NfsConfiguration conf, DatagramSocket registrationSocket, bool allowInsecurePorts
             )
     : base(RpcProgramNfs3.CreateRpcProgramNfs3(conf, registrationSocket, allowInsecurePorts
                                                ), conf)
 {
     mountd = new Mountd(conf, registrationSocket, allowInsecurePorts);
 }
コード例 #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestClientAccessPrivilegeForRemove()
        {
            // Configure ro access for nfs1 service
            config.Set("dfs.nfs.exports.allowed.hosts", "* ro");
            // Start nfs
            Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3 nfs = new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3
                                                           (config);
            nfs.StartServiceInternal(false);
            RpcProgramNfs3 nfsd = (RpcProgramNfs3)nfs.GetRpcProgram();
            // Create a remove request
            HdfsFileStatus status  = nn.GetRpcServer().GetFileInfo(testdir);
            long           dirId   = status.GetFileId();
            XDR            xdr_req = new XDR();
            FileHandle     handle  = new FileHandle(dirId);

            handle.Serialize(xdr_req);
            xdr_req.WriteString("f1");
            // Remove operation
            REMOVE3Response response = nfsd.Remove(xdr_req.AsReadOnlyWrap(), securityHandler,
                                                   new IPEndPoint("localhost", 1234));

            // Assert on return code
            NUnit.Framework.Assert.AreEqual("Incorrect return code", Nfs3Status.Nfs3errAcces,
                                            response.GetStatus());
        }
コード例 #3
0
        public static void Setup()
        {
            string currentUser = Runtime.GetProperty("user.name");

            config.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserGroupConfKey
                           (currentUser), "*");
            config.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserIpConfKey
                           (currentUser), "*");
            ProxyUsers.RefreshSuperUserGroupsConfiguration(config);
            cluster = new MiniDFSCluster.Builder(config).NumDataNodes(1).Build();
            cluster.WaitActive();
            hdfs = cluster.GetFileSystem();
            nn   = cluster.GetNameNode();
            // Use emphral port in case tests are running in parallel
            config.SetInt("nfs3.mountd.port", 0);
            config.SetInt("nfs3.server.port", 0);
            // Start nfs
            Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3 nfs3 = new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3
                                                            (config);
            nfs3.StartServiceInternal(false);
            nfsd            = (RpcProgramNfs3)nfs3.GetRpcProgram();
            securityHandler = Org.Mockito.Mockito.Mock <SecurityHandler>();
            Org.Mockito.Mockito.When(securityHandler.GetUser()).ThenReturn(Runtime.GetProperty
                                                                               ("user.name"));
        }
コード例 #4
0
ファイル: TestWrites.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.Exception"/>
        private void WaitWrite(RpcProgramNfs3 nfsd, FileHandle handle, int maxWaitTime)
        {
            int         waitedTime = 0;
            OpenFileCtx ctx        = nfsd.GetWriteManager().GetOpenFileCtxCache().Get(handle);

            NUnit.Framework.Assert.IsTrue(ctx != null);
            do
            {
                Sharpen.Thread.Sleep(3000);
                waitedTime += 3000;
                if (ctx.GetPendingWritesForTest().Count == 0)
                {
                    return;
                }
            }while (waitedTime < maxWaitTime);
            NUnit.Framework.Assert.Fail("Write can't finish.");
        }
コード例 #5
0
        public virtual void TestHttpServer()
        {
            Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3 nfs = new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3
                                                           (conf);
            nfs.StartServiceInternal(false);
            RpcProgramNfs3 nfsd       = (RpcProgramNfs3)nfs.GetRpcProgram();
            Nfs3HttpServer infoServer = nfsd.GetInfoServer();
            string         urlRoot    = infoServer.GetServerURI().ToString();
            // Check default servlets.
            string pageContents = DFSTestUtil.UrlGet(new Uri(urlRoot + "/jmx"));

            NUnit.Framework.Assert.IsTrue("Bad contents: " + pageContents, pageContents.Contains
                                              ("java.lang:type="));
            System.Console.Out.WriteLine("pc:" + pageContents);
            int port = infoServer.GetSecurePort();

            NUnit.Framework.Assert.IsTrue("Can't get https port", port > 0);
        }
コード例 #6
0
        public static void Setup()
        {
            string currentUser = Runtime.GetProperty("user.name");

            config.Set("fs.permissions.umask-mode", "u=rwx,g=,o=");
            config.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserGroupConfKey
                           (currentUser), "*");
            config.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserIpConfKey
                           (currentUser), "*");
            fsHelper = new FileSystemTestHelper();
            // Set up java key store
            string testRoot = fsHelper.GetTestRootDir();

            testRootDir = new FilePath(testRoot).GetAbsoluteFile();
            Path jksPath = new Path(testRootDir.ToString(), "test.jks");

            config.Set(DFSConfigKeys.DfsEncryptionKeyProviderUri, JavaKeyStoreProvider.SchemeName
                       + "://file" + jksPath.ToUri());
            ProxyUsers.RefreshSuperUserGroupsConfiguration(config);
            cluster = new MiniDFSCluster.Builder(config).NumDataNodes(1).Build();
            cluster.WaitActive();
            hdfs     = cluster.GetFileSystem();
            nn       = cluster.GetNameNode();
            dfsAdmin = new HdfsAdmin(cluster.GetURI(), config);
            // Use ephemeral ports in case tests are running in parallel
            config.SetInt("nfs3.mountd.port", 0);
            config.SetInt("nfs3.server.port", 0);
            // Start NFS with allowed.hosts set to "* rw"
            config.Set("dfs.nfs.exports.allowed.hosts", "* rw");
            nfs = new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3(config);
            nfs.StartServiceInternal(false);
            nfsd = (RpcProgramNfs3)nfs.GetRpcProgram();
            hdfs.GetClient().SetKeyProvider(nn.GetNamesystem().GetProvider());
            DFSTestUtil.CreateKey(TestKey, cluster, config);
            // Mock SecurityHandler which returns system user.name
            securityHandler = Org.Mockito.Mockito.Mock <SecurityHandler>();
            Org.Mockito.Mockito.When(securityHandler.GetUser()).ThenReturn(currentUser);
            // Mock SecurityHandler which returns a dummy username "harry"
            securityHandlerUnpriviledged = Org.Mockito.Mockito.Mock <SecurityHandler>();
            Org.Mockito.Mockito.When(securityHandlerUnpriviledged.GetUser()).ThenReturn("harry"
                                                                                        );
        }
コード例 #7
0
        public virtual void TestStart()
        {
            // Start minicluster
            NfsConfiguration config  = new NfsConfiguration();
            MiniDFSCluster   cluster = new MiniDFSCluster.Builder(config).NumDataNodes(1).Build
                                           ();

            cluster.WaitActive();
            // Use emphral port in case tests are running in parallel
            config.SetInt("nfs3.mountd.port", 0);
            config.SetInt("nfs3.server.port", 0);
            // Start nfs
            Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3 nfs3 = new Org.Apache.Hadoop.Hdfs.Nfs.Nfs3.Nfs3
                                                            (config);
            nfs3.StartServiceInternal(false);
            RpcProgramMountd mountd = (RpcProgramMountd)nfs3.GetMountd().GetRpcProgram();

            mountd.NullOp(new XDR(), 1234, Sharpen.Extensions.GetAddressByName("localhost"));
            RpcProgramNfs3 nfsd = (RpcProgramNfs3)nfs3.GetRpcProgram();

            nfsd.NullProcedure();
            cluster.Shutdown();
        }