server.py 2.49 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1
2
# (C) 2018 The University of Chicago
# See COPYRIGHT in top-level directory.
3
import _pybaketarget
Matthieu Dorier's avatar
Matthieu Dorier committed
4
5
import _pybakeserver
import pymargo
Matthieu Dorier's avatar
Matthieu Dorier committed
6
from pybake.target import BakeTargetID
Matthieu Dorier's avatar
Matthieu Dorier committed
7
8

def make_pool(name, size, mode):
9
    _pybakeserver.make_pool(name, size, mode)
Matthieu Dorier's avatar
Matthieu Dorier committed
10
11

class BakeProvider(pymargo.Provider):
12
13
14
    """
    The BakeProvide class wraps a C-level bake_provider_t object.
    """
Matthieu Dorier's avatar
Matthieu Dorier committed
15

16
17
18
19
20
    def __init__(self, engine, provider_id):
        """
        Constructor. Initializes a provider with an Engine and provider_id.
        """
        super(BakeProvider, self).__init__(engine, provider_id)
21
        self._provider = _pybakeserver.register(mid._mid, provider_id)
Matthieu Dorier's avatar
Matthieu Dorier committed
22

23
24
25
26
27
28
    def add_storage_target(self, path):
        """
        Adds a storage target to the provider.
        Returns a BakeTargetID instance that can be used to access the storage target.
        """
        tid = _pybakeserver.add_storage_target(self._provider, path)
29
        return BakeTargetID(tid)
Matthieu Dorier's avatar
Matthieu Dorier committed
30

31
    def remove_storage_target(self, target):
32
33
34
35
36
        """
        Removes a storage target from the provider. This does not delete the underlying file.
        The target argument must be a BakeTargetID object.
        """
        _pybakeserver.remove_storage_target(self._provider, target._tid)
Matthieu Dorier's avatar
Matthieu Dorier committed
37

38
    def remove_all_storage_targets(self):
39
40
41
42
        """
        Removes all the storage targets managed by this provider.
        """
        _pybakeserver.remove_all_storage_targets(self._provider)
Matthieu Dorier's avatar
Matthieu Dorier committed
43

44
    def count_storage_targets(self):
45
46
47
        """
        Returns the number of storage targets that this provider manages.
        """
48
        return _pybakeserver.count_storage_targets(self._provider)
Matthieu Dorier's avatar
Matthieu Dorier committed
49

50
    def list_storage_targets(self):
51
52
53
        """
        Returns the list of storage targets (BakeTargetIDs) that this provider manages.
        """
54
55
56
57
58
        l = _pybakeserver.list_storage_targets(self._provider)
        if(l is None):
            return []
        else:
            return [ BakeTargetID(tid) for tid in l ]
59

60
61
62
63
64
65
#    def set_target_xfer_buffer(self, target, count, size):
#        """
#        Sets the number and size of intermediate buffers that can be used to
#        execute transfers to a specific target.
#        """
#        _pybakeserver.set_target_xfer_buffer(self._provider, target._tid, count, size)
66

67
68
69
70
71
#    def set_target_xfer_concurrency(self, target, num_threads):
#        """
#        Sets the number of ULTs that can be used to execute transfers concurrently.
#        """
#        _pybakeserver.set_target_xfer_concurrency(self._provider, target._tid, num_threads)