コード例 #1
0
ファイル: client.py プロジェクト: Schevo/xdserver
 def _enumerate_database_names(self):
     count = read_int4(self.socket)
     while count > 0:
         count -= 1
         length = read_int4(self.socket)
         database_name = read(self.socket, length)
         yield database_name
コード例 #2
0
ファイル: utest_utils.py プロジェクト: cfobel/durus
 def read_write_int4(self):
     s = BytesIO()
     for x in (0, 1, 2**30):
         s.seek(0)
         write_int4(s, x)
         s.seek(0)
         assert x == read_int4(s)
コード例 #3
0
ファイル: storage_server.py プロジェクト: nascheme/durus
 def handle_B(self, s):
     # bulk read of objects
     number_of_oids = read_int4(s)
     oid_str = read(s, 8 * number_of_oids)
     oids = split_oids(oid_str)
     for oid in oids:
         self._send_load_response(s, oid)
コード例 #4
0
ファイル: client_storage.py プロジェクト: Schevo/durus
 def end(self, handle_invalidations=None):
     write(self.s, 'C')
     n = read_int4(self.s)
     oid_list = []
     if n != 0:
         packed_oids = read(self.s, n*8)
         oid_list = split_oids(packed_oids)
         try:
             handle_invalidations(oid_list)
         except ConflictError:
             self.transaction_new_oids.reverse()
             self.oid_pool.extend(self.transaction_new_oids)
             assert len(self.oid_pool) == len(set(self.oid_pool))
             self.begin() # clear out records and transaction_new_oids.
             write_int4(self.s, 0) # Tell server we are done.
             raise
     tdata = []
     for oid, record in iteritems(self.records):
         tdata.append(int4_to_str(8 + len(record)))
         tdata.append(as_bytes(oid))
         tdata.append(record)
     tdata = join_bytes(tdata)
     write_int4_str(self.s, tdata)
     self.records.clear()
     if len(tdata) > 0:
         status = read(self.s, 1)
         if status == STATUS_OKAY:
             pass
         elif status == STATUS_INVALID:
             raise WriteConflictError()
         else:
             raise ProtocolError('server returned invalid status %r' % status)
コード例 #5
0
ファイル: storage_server.py プロジェクト: cfobel/durus
 def handle_B(self, s):
     # bulk read of objects
     number_of_oids = read_int4(s)
     oid_str = read(s, 8 * number_of_oids)
     oids = split_oids(oid_str)
     for oid in oids:
         self._send_load_response(s, oid)
コード例 #6
0
 def end(self, handle_invalidations=None):
     write(self.s, 'C')
     n = read_int4(self.s)
     oid_list = []
     if n != 0:
         packed_oids = read(self.s, n * 8)
         oid_list = split_oids(packed_oids)
         try:
             handle_invalidations(oid_list)
         except ConflictError:
             self.transaction_new_oids.reverse()
             self.oid_pool.extend(self.transaction_new_oids)
             assert len(self.oid_pool) == len(set(self.oid_pool))
             self.begin()  # clear out records and transaction_new_oids.
             write_int4(self.s, 0)  # Tell server we are done.
             raise
     tdata = []
     for oid, record in iteritems(self.records):
         tdata.append(int4_to_str(8 + len(record)))
         tdata.append(as_bytes(oid))
         tdata.append(record)
     tdata = join_bytes(tdata)
     write_int4_str(self.s, tdata)
     self.records.clear()
     if len(tdata) > 0:
         status = read(self.s, 1)
         if status == STATUS_OKAY:
             pass
         elif status == STATUS_INVALID:
             raise WriteConflictError()
         else:
             raise ProtocolError('server returned invalid status %r' %
                                 status)
コード例 #7
0
ファイル: client_storage.py プロジェクト: Schevo/durus
 def sync(self):
     write(self.s, 'S')
     n = read_int4(self.s)
     if n == 0:
         packed_oids = ''
     else:
         packed_oids = read(self.s, n*8)
     return split_oids(packed_oids)
コード例 #8
0
 def sync(self):
     write(self.s, 'S')
     n = read_int4(self.s)
     if n == 0:
         packed_oids = ''
     else:
         packed_oids = read(self.s, n * 8)
     return split_oids(packed_oids)
コード例 #9
0
ファイル: client.py プロジェクト: Schevo/xdserver
 def sync(self):
     self._send_command('S')
     n = read_int4(self.socket)
     if n == 0:
         packed_oids = ''
     else:
         packed_oids = read(self.socket, 8 * n)
     return split_oids(packed_oids)
コード例 #10
0
ファイル: client_storage.py プロジェクト: Schevo/durus
 def _get_load_response(self, oid):
     status = read(self.s, 1)
     if status == STATUS_OKAY:
         pass
     elif status == STATUS_INVALID:
         raise ReadConflictError([oid])
     elif status == STATUS_KEYERROR:
         raise DurusKeyError(oid)
     else:
         raise ProtocolError('status=%r, oid=%r' % (status, oid))
     n = read_int4(self.s)
     record = read(self.s, n)
     return record
コード例 #11
0
 def _get_load_response(self, oid):
     status = read(self.s, 1)
     if status == STATUS_OKAY:
         pass
     elif status == STATUS_INVALID:
         raise ReadConflictError([oid])
     elif status == STATUS_KEYERROR:
         raise DurusKeyError(oid)
     else:
         raise ProtocolError('status=%r, oid=%r' % (status, oid))
     n = read_int4(self.s)
     record = read(self.s, n)
     return record