Commit 773693f8 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

pithos: Register commission serials to allow for recoery

Refs: #3594
parent e264d084
......@@ -42,8 +42,8 @@ def create_tables(engine):
metadata = MetaData()
columns = []
columns.append(Column('serial', BigInteger, primary_key=True))
config = Table('qh_serials', metadata, *columns, mysql_engine='InnoDB')
Table('qh_serials', metadata, *columns, mysql_engine='InnoDB')
metadata.create_all(engine)
return metadata.sorted_tables
......@@ -69,13 +69,41 @@ class QuotaholderSerial(DBWorker):
rows = r.fetchall()
r.close()
return rows
def lookup(self, serials):
"""Return the serials."""
if not serials:
return []
s = select([self.qh_serials.c.serial])
s = s.where(self.qh_serials.c.serial.in_(serials))
r = self.conn.execute(s)
rows = r.fetchall()
r.close()
return [row[0] for row in rows]
def insert_serial(self, serial):
"""Insert a serial.
"""
s = self.qh_serials.insert()
r = self.conn.execute(s, serial=serial)
inserted_primary_key = r.inserted_primary_key[0]
r.close()
return inserted_primary_key
\ No newline at end of file
def insert_many(self, serials):
"""Insert multiple serials.
"""
r = self.conn.execute(
self.qh_serials.insert(),
list({'serial':s} for s in serials)
)
r.close()
def delete_many(self, serials):
if not serials:
return
st = self.qh_serials.delete().where(
self.qh_serials.c.serial.in_(serials)
)
self.conn.execute(st).close()
......@@ -123,6 +123,7 @@ def backend_method(func=None, autocommit=1):
for m in self.messages:
self.queue.send(*m)
if serials:
self.quotaholder_serials.insert_many(serials)
self.quotaholder.accept_commission(
context = {},
clientkey = 'pithos',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment