Example #1
0
 def _query(options, *args, **kwargs):
     # If we're allowing secondary read then raise when reading a chunk.
     # We should attempt a call to primary only subsequently.
     if args[0] == 'arctic_{}'.format(library_name) and \
                 bool(options & _QUERY_OPTIONS['slave_okay']) == True:
         allow_secondary[0] = False
         raise OperationFailure("some_error")
     return __query(options, *args, **kwargs)
Example #2
0
 def _query(options, *args, **kwargs):
     # If we're allowing secondary read then raise when reading a chunk.
     # We should attempt a call to primary only subsequently.
     if args[0] == 'arctic_{}'.format(library_name) and \
                 bool(options & _QUERY_OPTIONS['slave_okay']) == True:
         allow_secondary[0] = False
         raise OperationFailure("some_error")
     return __query(options, *args, **kwargs)
Example #3
0
 def _query(options, *args, **kwargs):
     # If we're allowing secondary read and an error occurs when reading a chunk.
     # We should attempt a call to primary only subsequently.
     # In newer MongoDBs we query <database>.$cmd rather than <database>.<collection>
     if args[0].startswith('arctic_{}.'.format(library_name.split('.')[0])) and \
                 bool(options & _QUERY_OPTIONS['slave_okay']) == True:
         allow_secondary[0] = False
         raise OperationFailure("some_error")
     return __query(options, *args, **kwargs)
Example #4
0
 def _query(options, *args, **kwargs):
     # If we're allowing secondary read and an error occurs when reading a chunk.
     # We should attempt a call to primary only subsequently.
     # In newer MongoDBs we query <database>.$cmd rather than <database>.<collection>
     if args[0].startswith('arctic_{}.'.format(library_name.split('.')[0])) and \
                 bool(options & _QUERY_OPTIONS['slave_okay']) == True:
         allow_secondary[0] = False
         raise OperationFailure("some_error")
     return __query(options, *args, **kwargs)
Example #5
0
 def _internal_query(options, *args, **kwargs):
     coll_name = args[0]
     data_coll_name = 'arctic_{}'.format(library_name)
     versions_coll_name = data_coll_name + '.versions'
     if allow_secondary and coll_name in (data_coll_name, versions_coll_name):
         # Reads to the Version and Chunks collections are allowed to slaves
         assert bool(options & _QUERY_OPTIONS['slave_okay']) == allow_secondary, "{}: options:{}".format(coll_name, options)
     elif '.$cmd' not in coll_name:
         # All other collections we force PRIMARY read.
         assert bool(options & _QUERY_OPTIONS['slave_okay']) == False, "{}: options:{}".format(coll_name, options)
     return __query(options, *args, **kwargs)
Example #6
0
 def _internal_query(options, *args, **kwargs):
     coll_name = args[0]
     data_coll_name = 'arctic_{}'.format(library_name)
     versions_coll_name = data_coll_name + '.versions'
     if allow_secondary and coll_name in (data_coll_name, versions_coll_name):
         # Reads to the Version and Chunks collections are allowed to slaves
         assert bool(options & _QUERY_OPTIONS['slave_okay']) == allow_secondary, "{}: options:{}".format(coll_name, options)
     elif '.$cmd' not in coll_name:
         # All other collections we force PRIMARY read.
         assert bool(options & _QUERY_OPTIONS['slave_okay']) == False, "{}: options:{}".format(coll_name, options)
     return __query(options, *args, **kwargs)