Exemplo n.º 1
0
 def deleteObject(self, oid, serial, transaction):
     try:
         self.app.store(oid, serial, None, None, transaction)
     except Exception:
         logging.exception('oid=%r, serial=%r, transaction=%r', oid, serial,
                           transaction)
         raise
Exemplo n.º 2
0
 def checkCurrentSerialInTransaction(self, oid, serial, transaction):
     try:
         self.app.checkCurrentSerialInTransaction(oid, serial, transaction)
     except Exception:
         logging.exception('oid=%r, serial=%r, transaction=%r', oid, serial,
                           transaction)
         raise
Exemplo n.º 3
0
 def copyTransactionsFrom(self, source, verbose=False):
     """ Zope compliant API """
     try:
         return self.app.importFrom(self, source)
     except Exception:
         logging.exception('source=%r', source)
         raise
Exemplo n.º 4
0
 def _connect(self):
     kwd = {'db' : self.db, 'user' : self.user}
     if self.passwd is not None:
         kwd['passwd'] = self.passwd
     if self.socket:
         kwd['unix_socket'] = os.path.expanduser(self.socket)
     logging.info('connecting to MySQL on the database %s with user %s',
                  self.db, self.user)
     if self._wait < 0:
         timeout_at = None
     else:
         timeout_at = time.time() + self._wait
     while True:
         try:
             self.conn = MySQLdb.connect(**kwd)
             break
         except Exception:
             if timeout_at is not None and time.time() >= timeout_at:
                 raise
             logging.exception('Connection to MySQL failed, retrying.')
             time.sleep(1)
     self._active = 0
     conn = self.conn
     conn.autocommit(False)
     conn.query("SET SESSION group_concat_max_len = %u" % (2**32-1))
     conn.set_sql_mode("TRADITIONAL,NO_ENGINE_SUBSTITUTION")
     conn.query("SHOW VARIABLES WHERE variable_name='max_allowed_packet'")
     r = conn.store_result()
     (name, value), = r.fetch_row(r.num_rows())
     if int(value) < self._max_allowed_packet:
         raise DatabaseFailure("Global variable %r is too small."
             " Minimal value must be %uk."
             % (name, self._max_allowed_packet // 1024))
     self._max_allowed_packet = int(value)
Exemplo n.º 5
0
 def tpc_abort(self, transaction):
     """Abort current transaction."""
     txn_context = self._txn_container.pop(transaction)
     if txn_context is None:
         return
     ttid = txn_context['ttid']
     p = Packets.AbortTransaction(ttid)
     getConnForNode = self.cp.getConnForNode
     # cancel transaction one all those nodes
     nodes = txn_context['involved_nodes']
     nodes |= txn_context['checked_nodes']
     for node in nodes:
         conn = getConnForNode(node)
         if conn is None:
             continue
         try:
             conn.notify(p)
         except:
             logging.exception(
                 'Exception in tpc_abort while notifying'
                 'storage node %r of abortion, ignoring.', conn)
     conn = self.master_conn
     if conn is not None:
         conn.notify(p)
     # We don't need to flush queue, as it won't be reused by future
     # transactions (deleted on next line & indexed by transaction object
     # instance).
     self.dispatcher.forget_queue(txn_context['queue'], flush_queue=False)
Exemplo n.º 6
0
 def tpc_abort(self, transaction):
     """Abort current transaction."""
     txn_context = self._txn_container.pop(transaction)
     if txn_context is None:
         return
     ttid = txn_context['ttid']
     p = Packets.AbortTransaction(ttid)
     getConnForNode = self.cp.getConnForNode
     # cancel transaction one all those nodes
     nodes = txn_context['involved_nodes']
     nodes |= txn_context['checked_nodes']
     for node in nodes:
         conn = getConnForNode(node)
         if conn is None:
             continue
         try:
             conn.notify(p)
         except:
             logging.exception('Exception in tpc_abort while notifying'
                 'storage node %r of abortion, ignoring.', conn)
     conn = self.master_conn
     if conn is not None:
         conn.notify(p)
     # We don't need to flush queue, as it won't be reused by future
     # transactions (deleted on next line & indexed by transaction object
     # instance).
     self.dispatcher.forget_queue(txn_context['queue'], flush_queue=False)
Exemplo n.º 7
0
 def tpc_vote(self, transaction):
     try:
         return self.app.tpc_vote(transaction)
     except ConflictError:
         raise
     except Exception:
         logging.exception('transaction=%r', transaction)
         raise
Exemplo n.º 8
0
 def loadSerial(self, oid, serial):
     try:
         return self.app.load(oid, serial)[0]
     except NEOStorageNotFoundError:
         raise POSException.POSKeyError(oid)
     except Exception:
         logging.exception('oid=%r, serial=%r', oid, serial)
         raise
Exemplo n.º 9
0
 def run(self):
     try:
         self._run()
     except Exception:
         logging.exception('Pre-mortem data:')
         self.log()
         logging.flush()
         raise
Exemplo n.º 10
0
 def undo(self, transaction_id, txn):
     try:
         return self.app.undo(transaction_id, txn)
     except (ConflictError, UndoError):
         raise
     except Exception:
         logging.exception('transaction_id=%r, txn=%r', transaction_id, txn)
         raise
Exemplo n.º 11
0
 def run(self):
     try:
         self._run()
     except Exception:
         logging.exception('Pre-mortem data:')
         self.log()
         logging.flush()
         raise
Exemplo n.º 12
0
 def getTid(self, oid):
     try:
         return self.app.getLastTID(oid)
     except NEOStorageNotFoundError:
         raise KeyError
     except Exception:
         logging.exception('oid=%r', oid)
         raise
Exemplo n.º 13
0
 def history(self, oid, *args, **kw):
     try:
         return self.app.history(oid, *args, **kw)
     except NEOStorageNotFoundError:
         raise POSException.POSKeyError(oid)
     except Exception:
         logging.exception('oid=%r', oid)
         raise
Exemplo n.º 14
0
 def loadEx(self, oid, version):
     try:
         data, serial, _ = self.app.load(oid)
     except NEOStorageNotFoundError:
         raise POSException.POSKeyError(oid)
     except Exception:
         logging.exception('oid=%r', oid)
         raise
     return data, serial, ''
Exemplo n.º 15
0
 def tpc_begin(self, transaction, tid=None, status=' '):
     """
     Note: never blocks in NEO.
     """
     try:
         return self.app.tpc_begin(self, transaction, tid, status)
     except Exception:
         logging.exception('transaction=%r, tid=%r', transaction, tid)
         raise
Exemplo n.º 16
0
 def pack(self, t, referencesf, gc=False):
     if gc:
         logging.warning(
             'Garbage Collection is not available in NEO,'
             ' please use an external tool. Packing without GC.')
     try:
         self.app.pack(t)
     except Exception:
         logging.exception('pack_time=%r', t)
         raise
Exemplo n.º 17
0
 def store(self, oid, serial, data, version, transaction):
     assert version == '', 'Versions are not supported'
     try:
         return self.app.store(oid, serial, data, version, transaction)
     except ConflictError:
         raise
     except Exception:
         logging.exception('oid=%r, serial=%r, transaction=%r', oid, serial,
                           transaction)
         raise
Exemplo n.º 18
0
 def loadBefore(self, oid, tid):
     try:
         return self.app.load(oid, None, tid)
     except NEOStorageDoesNotExistError:
         raise POSException.POSKeyError(oid)
     except NEOStorageNotFoundError:
         return None
     except Exception:
         logging.exception('oid=%r, tid=%r', oid, tid)
         raise
Exemplo n.º 19
0
 def load(self, oid, version=''):
     # XXX: interface definition states that version parameter is
     # mandatory, while some ZODB tests do not provide it. For now, make
     # it optional.
     assert version == '', 'Versions are not supported'
     try:
         return self.app.load(oid)[:2]
     except NEOStorageNotFoundError:
         raise POSException.POSKeyError(oid)
     except Exception:
         logging.exception('oid=%r', oid)
         raise
Exemplo n.º 20
0
 def log(cls):
     try:
         if cls.filter_queue:
             logging.info('%s:', cls.__name__)
             for conn, queue in cls.filter_queue.iteritems():
                 app = NEOThreadedTest.getConnectionApp(conn)
                 logging.info('  %s %s:', uuid_str(app.uuid), conn)
                 for p in queue:
                     logging.info('    #0x%04x %s', p.getId(),
                                  p.__class__.__name__)
     except Exception:
         logging.exception('')
Exemplo n.º 21
0
 def _getFinalTID(self, ttid):
     try:
         p = Packets.AskFinalTID(ttid)
         while 1:
             try:
                 tid = self._askPrimary(p)
                 break
             except ConnectionClosed:
                 pass
         if tid == MAX_TID:
             while 1:
                 try:
                     return self._askStorageForRead(ttid, p)
                 except NEOPrimaryMasterLost:
                     pass
         elif tid:
             return tid
     except Exception:
         logging.exception("Failed to get final tid for TXN %s", dump(ttid))
Exemplo n.º 22
0
 def _getFinalTID(self, ttid):
     try:
         p = Packets.AskFinalTID(ttid)
         while 1:
             try:
                 tid = self._askPrimary(p)
                 break
             except ConnectionClosed:
                 pass
         if tid == MAX_TID:
             while 1:
                 for _, conn in self.cp.iterateForObject(ttid,
                                                         readable=True):
                     try:
                         return self._askStorage(conn, p)
                     except ConnectionClosed:
                         pass
                 self._getMasterConnection()
         elif tid:
             return tid
     except Exception:
         logging.exception("Failed to get final tid for TXN %s", dump(ttid))
Exemplo n.º 23
0
 def _getFinalTID(self, ttid):
     try:
         p = Packets.AskFinalTID(ttid)
         while 1:
             try:
                 tid = self._askPrimary(p)
                 break
             except ConnectionClosed:
                 pass
         if tid == MAX_TID:
             while 1:
                 for _, conn in self.cp.iterateForObject(
                         ttid, readable=True):
                     try:
                         return self._askStorage(conn, p)
                     except ConnectionClosed:
                         pass
                 self._getMasterConnection()
         elif tid:
             return tid
     except Exception:
         logging.exception("Failed to get final tid for TXN %s",
                           dump(ttid))
Exemplo n.º 24
0
 def tpc_finish(self, transaction, f=None):
     try:
         return self.app.tpc_finish(transaction, f)
     except Exception:
         logging.exception('transaction=%r', transaction)
         raise
Exemplo n.º 25
0
 def undoLog(self, first=0, last=-20, filter=None):
     try:
         return self.app.undoLog(first, last, filter)
     except Exception:
         logging.exception('first=%r, last=%r', first, last)
         raise
Exemplo n.º 26
0
 def __len__(self):
     try:
         return self.app.getObjectCount()
     except Exception:
         logging.exception('')
         raise
Exemplo n.º 27
0
 def tpc_abort(self, transaction):
     try:
         return self.app.tpc_abort(transaction)
     except Exception:
         logging.exception('transaction=%r', transaction)
         raise
Exemplo n.º 28
0
 def new_oid(self):
     try:
         return self.app.new_oid()
     except Exception:
         logging.exception('')
         raise