Exemplo n.º 1
0
 def writeTransaction(self, tid, serial, oids, ude):
     packed = ''.join(oid for oid in oids)
     k = Key(self._bucket)
     k.key = 'type:transaction,order:%s,tid:%s' % (order_repr(serial),
                                                   tid_repr(tid))
     if DEBUG: print 'COMMIT %s' %k.key
     k.set_contents_from_string(packed)
Exemplo n.º 2
0
 def storePickle(self, oid, tid, prev_tid, data):
     '''Save the data to s3'''
     k = Key(self._bucket)
     k.key = 'type:record,oid:%s,tid:%s' % (oid_repr(oid), tid_repr(tid))
     if DEBUG: print 'STORE %s' % k.key
     for n in xrange(RETRIES):
         try:
             return k.set_contents_from_string(data)
         except:
             if DEBUG: print 'RETRY %s' % n                
             time.sleep(SLEEPTIME)
     return k.set_contents_from_string(data)
Exemplo n.º 3
0
 def loadPickle(self, oid, tid):
     """Actually get the data from s3"""
     k = Key(self._bucket)
     k.key = 'type:record,oid:%s,tid:%s' % (oid_repr(oid), tid_repr(tid))
     if DEBUG: print 'LOAD  %s' % k.key
     for n in xrange(RETRIES):
         try:
             return k.get_contents_as_string()
         except S3ResponseError:
             if DEBUG: print 'RETRY %s' % n
             time.sleep(SLEEPTIME)
     return k.get_contents_as_string()
Exemplo n.º 4
0
    def indexTransaction(self, tid, serial, oids):
        for oid in oids:
            k = Key(self._bucket)
            k.key = 'type:index_oid,oid:%s,serial:%s,tid:%s' %(
                oid_repr(oid),
                serial_repr(serial),
                tid_repr(tid))
            k.set_contents_from_string('')
        k = Key(self._bucket)

        # Index tid to serial
        k.key = 'type:index_tid,tid:%s,serial:%s' %(
                tid_repr(tid),
                serial_repr(serial))
        k.set_contents_from_string('')

        # Index the highest committed serial
        k = Key(self._bucket)
        k.key = 'type:index_serial,serial:%s,tid:%s' %(
                serial_repr(serial),
                tid_repr(tid))
        k.set_contents_from_string('')