def _redis_master(self):
     try:
         if not self._master:
             self._master = self._sentinel.master_for(self._master_group)
         return self._master
     except redis_sentinel.MasterNotFoundError:
         raise zmq_matchmaker_base.MatchmakerUnavailable()
Beispiel #2
0
 def acquire_connection(self, request):
     if not self.publishers:
         raise zmq_matchmaker_base.MatchmakerUnavailable()
     socket = self.sockets_manager.get_socket()
     publishers = list(self.publishers)
     random.shuffle(publishers)
     for publisher in publishers:
         socket.connect_to_host(publisher)
     return socket
Beispiel #3
0
 def func_wrapper(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except redis.ConnectionError:
         LOG.warning(_LW("Redis is currently not available. "
                         "Messages are being sent to known targets using "
                         "existing connections. But new nodes "
                         "can not be discovered until Redis is up "
                         "and running."))
         raise zmq_matchmaker_base.MatchmakerUnavailable()
 def func_wrapper(self, *args, **kwargs):
     # try to perform a read operation from any available and ready host
     for redis_instance in self._redis_instances:
         if not redis_instance._is_available \
                 or redis_instance._ready_from > time.time():
             continue
         try:
             return func(self, redis_instance, *args, **kwargs)
         except redis.ConnectionError:
             LOG.warning(_LW("Redis host %s is not available now."),
                         redis_instance._address)
             redis_instance._is_available = False
             redis_instance._ready_from = float("inf")
     raise zmq_matchmaker_base.MatchmakerUnavailable()
 def func_wrapper(self, *args, **kwargs):
     # try to perform a write operation to all available hosts
     success = False
     for redis_instance in self._redis_instances:
         if not redis_instance._is_available:
             continue
         try:
             func(self, redis_instance, *args, **kwargs)
             success = True
         except redis.ConnectionError:
             LOG.warning(_LW("Redis host %s is not available now."),
                         redis_instance._address)
             redis_instance._is_available = False
             redis_instance._ready_from = float("inf")
     if not success:
         raise zmq_matchmaker_base.MatchmakerUnavailable()
 def acquire_connection(self, request):
     if not self.publishers:
         raise zmq_matchmaker_base.MatchmakerUnavailable()
     socket = self.sockets_manager.get_socket()
     socket.connect_to_host(random.choice(tuple(self.publishers)))
     return socket