Ejemplo n.º 1
0
        public virtual void TestManyDfsClientsWhereSomeNotOpen()
        {
            // First DFSClient has no files open so doesn't renew leases.
            DFSClient mockClient1 = CreateMockClient();

            Org.Mockito.Mockito.DoReturn(false).When(mockClient1).RenewLease();
            NUnit.Framework.Assert.AreSame(renewer, LeaseRenewer.GetInstance(FakeAuthority, FakeUgiA
                                                                             , mockClient1));
            // Set up a file so that we start renewing our lease.
            DFSOutputStream mockStream1 = Org.Mockito.Mockito.Mock <DFSOutputStream>();
            long            fileId      = 456L;

            renewer.Put(fileId, mockStream1, mockClient1);
            // Second DFSClient does renew lease
            DFSClient mockClient2 = CreateMockClient();

            Org.Mockito.Mockito.DoReturn(true).When(mockClient2).RenewLease();
            NUnit.Framework.Assert.AreSame(renewer, LeaseRenewer.GetInstance(FakeAuthority, FakeUgiA
                                                                             , mockClient2));
            // Set up a file so that we start renewing our lease.
            DFSOutputStream mockStream2 = Org.Mockito.Mockito.Mock <DFSOutputStream>();

            renewer.Put(fileId, mockStream2, mockClient2);
            // Wait for lease to get renewed
            GenericTestUtils.WaitFor(new _Supplier_156(mockClient1, mockClient2), 100, 10000);
            // should not throw!
            renewer.CloseFile(fileId, mockClient1);
            renewer.CloseFile(fileId, mockClient2);
        }
Ejemplo n.º 2
0
        public virtual void TestInstanceSharing()
        {
            // Two lease renewers with the same UGI should return
            // the same instance
            LeaseRenewer lr = LeaseRenewer.GetInstance(FakeAuthority, FakeUgiA, MockDfsclient
                                                       );
            LeaseRenewer lr2 = LeaseRenewer.GetInstance(FakeAuthority, FakeUgiA, MockDfsclient
                                                        );

            NUnit.Framework.Assert.AreSame(lr, lr2);
            // But a different UGI should return a different instance
            LeaseRenewer lr3 = LeaseRenewer.GetInstance(FakeAuthority, FakeUgiB, MockDfsclient
                                                        );

            NUnit.Framework.Assert.AreNotSame(lr, lr3);
            // A different authority with same UGI should also be a different
            // instance.
            LeaseRenewer lr4 = LeaseRenewer.GetInstance("someOtherAuthority", FakeUgiB, MockDfsclient
                                                        );

            NUnit.Framework.Assert.AreNotSame(lr, lr4);
            NUnit.Framework.Assert.AreNotSame(lr3, lr4);
        }
Ejemplo n.º 3
0
 public virtual void SetupMocksAndRenewer()
 {
     MockDfsclient = CreateMockClient();
     renewer       = LeaseRenewer.GetInstance(FakeAuthority, FakeUgiA, MockDfsclient);
     renewer.SetGraceSleepPeriod(FastGracePeriod);
 }