Exemple #1
0
    def __init__(self,
                 master_nodes,
                 name,
                 compress=True,
                 cache_size=None,
                 **kw):
        super(Application, self).__init__(parseMasterList(master_nodes), name,
                                          **kw)
        # Internal Attributes common to all thread
        self._db = None
        self.primary_master_node = None
        self.trying_master_node = None

        # no self-assigned NID, primary master will supply us one
        self._cache = ClientCache() if cache_size is None else \
                      ClientCache(max_size=cache_size)
        self._loading_oid = None
        self.new_oids = ()
        self.last_oid = '\0' * 8
        self.storage_event_handler = storage.StorageEventHandler(self)
        self.storage_bootstrap_handler = storage.StorageBootstrapHandler(self)
        self.storage_handler = storage.StorageAnswersHandler(self)
        self.primary_handler = master.PrimaryAnswersHandler(self)
        self.primary_bootstrap_handler = master.PrimaryBootstrapHandler(self)
        self.notifications_handler = master.PrimaryNotificationsHandler(self)
        self._txn_container = TransactionContainer()
        # Lock definition :
        # _load_lock is used to make loading and storing atomic
        lock = Lock()
        self._load_lock_acquire = lock.acquire
        self._load_lock_release = lock.release
        # _oid_lock is used in order to not call multiple oid
        # generation at the same time
        lock = Lock()
        self._oid_lock_acquire = lock.acquire
        self._oid_lock_release = lock.release
        lock = Lock()
        # _cache_lock is used for the client cache
        self._cache_lock_acquire = lock.acquire
        self._cache_lock_release = lock.release
        # _connecting_to_master_node is used to prevent simultaneous master
        # node connection attempts
        self._connecting_to_master_node = Lock()
        # same for storage nodes
        self._connecting_to_storage_node = Lock()
        self._node_failure_dict = {}
        self.compress = getCompress(compress)
Exemple #2
0
 def __init__(self, app):
     self.app = app
     self.connection_dict = {}
     # Define a lock in order to create one connection to
     # a storage node at a time to avoid multiple connections
     # to the same node.
     self._lock = Lock()
     self.node_failure_dict = {}