示例#1
0
    def test_unload_thrift_api_accepts_single_dot_as_root(self) -> None:
        self.write_file("testfile.txt", "unload test case")

        age = TimeSpec()
        age.seconds = 0
        age.nanoSeconds = 0
        unload_count = self.client.unloadInodeForPath(self.mount_path_bytes, b".", age)

        self.assertGreater(
            unload_count, 0, "Number of loaded inodes should reduce after unload"
        )
示例#2
0
    def test_unload_thrift_api_accepts_single_dot_as_root(self) -> None:
        self.write_file("testfile.txt", "unload test case")

        age = TimeSpec()
        age.seconds = 0
        age.nanoSeconds = 0
        unload_count = self.client.unloadInodeForPath(self.mount_path_bytes, b".", age)

        self.assertGreater(
            unload_count, 0, "Number of loaded inodes should reduce after unload"
        )
示例#3
0
def do_unload_inodes(args: argparse.Namespace):
    config = cmd_util.create_config(args)
    mount, rel_path = get_mount_path(args.path)

    with config.get_thrift_client() as client:
        # set the age in nanoSeconds
        age = TimeSpec()
        age.seconds = int(args.age)
        age.nanoSeconds = int((args.age - age.seconds) * 10**9)
        count = client.unloadInodeForPath(mount, rel_path, age)

        print(f'Unloaded {count} inodes under {mount}/{rel_path}')
示例#4
0
文件: debug.py 项目: jsoref/eden
    def run(self, args: argparse.Namespace) -> int:
        instance, checkout, rel_path = cmd_util.require_checkout(
            args, args.path)

        with instance.get_thrift_client() as client:
            # set the age in nanoSeconds
            age = TimeSpec()
            age.seconds = int(args.age)
            age.nanoSeconds = int((args.age - age.seconds) * 10**9)
            count = client.unloadInodeForPath(bytes(checkout.path),
                                              bytes(rel_path), age)

            unload_path = checkout.path.joinpath(rel_path)
            print(f"Unloaded {count} inodes under {unload_path}")

        return 0
示例#5
0
    def run(self, args: argparse.Namespace) -> int:
        instance, checkout, rel_path = cmd_util.require_checkout(args, args.path)

        with instance.get_thrift_client() as client:
            # set the age in nanoSeconds
            age = TimeSpec()
            age.seconds = int(args.age)
            age.nanoSeconds = int((args.age - age.seconds) * 10 ** 9)
            count = client.unloadInodeForPath(
                bytes(checkout.path), bytes(rel_path), age
            )

            unload_path = checkout.path.joinpath(rel_path)
            print(f"Unloaded {count} inodes under {unload_path}")

        return 0
示例#6
0
    def test_unload_free_inodes(self):
        for i in range(100):
            self.write_file('testfile%d.txt' % i, 'unload test case')

        inode_count_before_unload = self.get_loaded_inodes_count('')
        self.assertGreater(inode_count_before_unload, 100,
                           'Number of loaded inodes should increase')

        age = TimeSpec()
        age.seconds = 0
        age.nanoSeconds = 0
        unload_count = self.client.unloadInodeForPath(self.mount, '', age)

        self.assertGreaterEqual(
            unload_count, 100,
            'Number of loaded inodes should reduce after unload')
示例#7
0
    def test_unload_free_inodes(self) -> None:
        for i in range(100):
            self.write_file("testfile%d.txt" % i, "unload test case")

        inode_count_before_unload = self.get_loaded_inodes_count("")
        self.assertGreater(inode_count_before_unload, 100,
                           "Number of loaded inodes should increase")

        age = TimeSpec()
        age.seconds = 0
        age.nanoSeconds = 0
        unload_count = self.client.unloadInodeForPath(self.mount_path_bytes,
                                                      b"", age)

        self.assertGreaterEqual(
            unload_count, 100,
            "Number of loaded inodes should reduce after unload")
示例#8
0
    def test_unload_free_inodes(self) -> None:
        for i in range(100):
            self.write_file("testfile%d.txt" % i, "unload test case")

        inode_count_before_unload = self.get_loaded_inodes_count("")
        self.assertGreater(
            inode_count_before_unload, 100, "Number of loaded inodes should increase"
        )

        age = TimeSpec()
        age.seconds = 0
        age.nanoSeconds = 0
        unload_count = self.client.unloadInodeForPath(self.mount_path_bytes, b"", age)

        self.assertGreaterEqual(
            unload_count, 100, "Number of loaded inodes should reduce after unload"
        )
示例#9
0
    def test_unload_free_inodes_age(self):
        age_to_unload = 10
        old_timestamp = time.time() - (age_to_unload * 2)

        # Load 100 inodes and set their atime to a very old value.
        for i in range(100):
            filename = os.path.join(self.mount, 'testfile_old%d.txt' % i)
            self.write_file(filename, 'unload test case')
            os.utime(filename, (old_timestamp, old_timestamp))

        # Load another 100 inodes whose atime is close to current time.
        for i in range(100):
            self.write_file('testfile_new%d.txt' % i, 'unload test case')

        inode_count_before_unload = self.get_loaded_inodes_count('')
        self.assertGreater(inode_count_before_unload, 200,
                           'Number of loaded inodes should increase')
        age = TimeSpec()
        age.seconds = age_to_unload
        age.nanoSeconds = 0
        unloaded_inode_count = self.client.unloadInodeForPath(
            self.mount, '', age)
        result = self.client.debugInodeStatus(self.mount, '')

        # Check if the inodes we are epecting to be unloaded are actually unloading.
        for item in result:
            for inode in item.entries:
                if inode.loaded:
                    # If a file is loaded check that it is not old file (not all the
                    # ones that are loaded are new files, there can be other files too).
                    self.assertFalse(
                        str(inode.name).find('testfile_old') != -1,
                        'old inodes should not be loaded')
                else:
                    # check that the inodes that are unloaded are not the new ones
                    # (not all the files that are unloaded are new ones).
                    self.assertFalse(
                        str(inode.name).find('testfile_new') != -1,
                        'new inodes should not be unloaded')

        self.assertEqual(unloaded_inode_count, 100,
                         'Only the old batch of inodes should unload')
示例#10
0
文件: debug.py 项目: cnmade/eden
def do_unload_inodes(args: argparse.Namespace):
    config = cmd_util.create_config(args)
    mount, rel_path = get_mount_path(args.path)

    with config.get_thrift_client() as client:
        inodeInfo_before_unload = client.debugInodeStatus(mount, rel_path)
        inodeCount_before_unload = get_loaded_inode_count(
            inodeInfo_before_unload)

        # set the age in nanoSeconds
        age = TimeSpec()
        age.seconds = int(args.age)
        age.nanoSeconds = int((args.age - age.seconds) * 10**9)
        client.unloadInodeForPath(mount, rel_path, age)

        inodeInfo_after_unload = client.debugInodeStatus(mount, rel_path)
        inodeCount_after_unload = get_loaded_inode_count(
            inodeInfo_after_unload)
        count = inodeCount_before_unload - inodeCount_after_unload
        print('Unloaded %s Inodes under the directory : %s' %
              (count, args.path))
示例#11
0
 def unload_one_inode_under(self, path):
     # TODO: To support unloading more than one inode, sum the return value
     # until count is reached our the attempt limit has been reached.
     remaining_attempts = 5
     while True:
         age = TimeSpec()  # zero
         with self.eden.get_thrift_client() as client:
             count = client.unloadInodeForPath(self.mount, path, age)
         if remaining_attempts == 1:
             self.assertEqual(1, count)
         elif count == 1:
             break
         else:
             remaining_attempts -= 1
             time.sleep(1)
             continue
示例#12
0
 def unload_inode_for_path(self, path: str = "") -> None:
     """path: relative path to a directory under the mount."""
     with self.create_thrift_client() as client:
         client.unloadInodeForPath(
             os.fsencode(self._mount_point), os.fsencode(path), age=TimeSpec(0, 0)
         )