Example #1
0
 def __init__(self, *args, **kwargs):
     self.make_reqid = itertools.count().next
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     self.compressor = self.decompressor = None
     self.event_watchers = {}
     Connection.__init__(self, *args, **kwargs)
Example #2
0
 def __init__(self, *args, **kwargs):
     self.reqid_slots = (1 << 128) - 1
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     self.compressor = self.decompressor = None
     self.event_watchers = {}
     Connection.__init__(self, *args, **kwargs)
Example #3
0
 def __init__(self, *args, **kwargs):
     self.reqid_slots = (1 << 128) - 1
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     self.compressor = self.decompressor = None
     self.event_watchers = {}
     Connection.__init__(self, *args, **kwargs)
Example #4
0
 def __init__(self, *args, **kwargs):
     self.make_reqid = itertools.count().next
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     self.compressor = self.decompressor = None
     self.event_watchers = {}
     Connection.__init__(self, *args, **kwargs)
Example #5
0
 def __init__(self, *args, **kwargs):
     self.responses = {}
     self.ids = range(0, 127)
     self.waiting = {}
     self.conn_ready = False
     self.compressor = self.decompressor = None
     self.event_watchers = {}
     Connection.__init__(self, *args, **kwargs)
Example #6
0
 def __init__(self, *args, **kwargs):
     _reqids = set(range(128))
     self.make_reqid = _reqids.pop
     self.return_reqids = _reqids.update
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     self.compressor = self.decompressor = None
     self.event_watchers = {}
     Connection.__init__(self, *args, **kwargs)
Example #7
0
 def __create_connection(self):
     return Connection(self.hostname,
                       port=self.port,
                       keyspace=self.keyspace,
                       username=self.username,
                       password=self.password,
                       decoder=self.decoder)
Example #8
0
 def execute(self, query, *args, **kwargs):
     """
     Execute a CQL query on a remote node.
     
     Params:
     * query .........: CQL query string.
     * args ..........: Query parameters.
     * compression ...: Query compression type (optional).
     """
     def _error(err):
         if isinstance(err, InvalidRequestException):
             raise CQLException("Bad Request: %s" % err.why)
         elif isinstance(err, TApplicationException):
             raise CQLException("Internal application error")
         elif isinstance(err, SchemaDisagreementException):
             raise CQLException("schema versions disagree, (try again later).")
         else:
             raise CQLException(err)
         
     def _success(response):
         if response.type == CqlResultType.ROWS:
             return RowsProxy(response.rows,
                              self.keyspace,
                              self.column_family,
                              self.decoder)
         if response.type == CqlResultType.INT:
             return response.num
         return None
         
     if kwargs.has_key("compression"):
         compress = kwargs.get("compression").upper()
     else:
         compress = DEFAULT_COMPRESSION
     
     compressed_query = connection.compress_query(self.prepare(query, *args),
                                                  compress)
     request_compression = getattr(Compression, compress)
     
     d = self.client.execute_cql_query(compressed_query,
                                                  request_compression)
     d.addCallbacks(_success, _error)
     return d
Example #9
0
 def __init__(self, *args, **kwargs):
     self.make_reqid = itertools.count().next
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     Connection.__init__(self, *args, **kwargs)
Example #10
0
 def __init__(self, *args, **kwargs):
     self.make_reqid = itertools.count().next
     self.responses = {}
     self.waiting = {}
     self.conn_ready = False
     Connection.__init__(self, *args, **kwargs)