Commit 9480f2e3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5e0639c1
......@@ -119,7 +119,7 @@ class ClientServiceHandler(MasterHandler):
self.app.tm.abort(tid, conn.getUUID())
# like ClientServiceHandler but read-only
# like ClientServiceHandler but read-only & only up-to backup_tid
class ClientROServiceHandler(ClientServiceHandler):
def _readOnly(self, *args, **kw): raise NotReadyError('read-only access')
......
......@@ -251,7 +251,7 @@ class Application(BaseApplication):
while not self.operational:
_poll()
self.ready = True
self.replicator.populate() # TODO study what's inside
self.replicator.populate()
self.master_conn.notify(Packets.NotifyReady())
def doOperation(self):
......
......@@ -65,15 +65,15 @@ class ClientOperationHandler(EventHandler):
assert node is not None, conn
self.app.nm.remove(node)
def abortTransaction(self, conn, ttid): # NOTE rw
def abortTransaction(self, conn, ttid):
self.app.tm.abort(ttid)
def askStoreTransaction(self, conn, ttid, *txn_info): # NOTE rw
def askStoreTransaction(self, conn, ttid, *txn_info):
self.app.tm.register(conn, ttid)
self.app.tm.vote(ttid, txn_info)
conn.answer(Packets.AnswerStoreTransaction())
def askVoteTransaction(self, conn, ttid): # NOTE rw
def askVoteTransaction(self, conn, ttid):
self.app.tm.vote(ttid)
conn.answer(Packets.AnswerVoteTransaction())
......@@ -111,7 +111,7 @@ class ClientOperationHandler(EventHandler):
logging.info('StoreObject delay: %.02fs', duration)
conn.answer(Packets.AnswerStoreObject(0, oid, serial))
def askStoreObject(self, conn, oid, serial, # NOTE rw
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, data_serial, ttid, unlock):
if 1 < compression:
raise ProtocolError('invalid compression value')
......@@ -145,10 +145,9 @@ class ClientOperationHandler(EventHandler):
tid_list = app.dm.getTIDList(first, last - first, partition_list)
conn.answer(Packets.AnswerTIDs(tid_list))
def askFinalTID(self, conn, ttid): # NOTE rw
def askFinalTID(self, conn, ttid):
conn.answer(Packets.AnswerFinalTID(self.app.tm.getFinalTID(ttid)))
# XXX not sure about rw (TODO recheck)
def askObjectUndoSerial(self, conn, ttid, ltid, undone_tid, oid_list):
app = self.app
findUndoTID = app.dm.findUndoTID
......@@ -191,7 +190,6 @@ class ClientOperationHandler(EventHandler):
p = Packets.AnswerObjectHistory(oid, history_list)
conn.answer(p)
# XXX should not be rw, but recheck
def askCheckCurrentSerial(self, conn, ttid, serial, oid):
self.app.tm.register(conn, ttid)
self._askCheckCurrentSerial(conn, ttid, serial, oid, time.time())
......@@ -224,3 +222,16 @@ class ClientOperationHandler(EventHandler):
logging.info('CheckCurrentSerial delay: %.02fs', duration)
conn.answer(Packets.AnswerCheckCurrentSerial(0, oid, serial))
# like ClientOperationHandler but read-only & only up-to backup_tid
class ClientROOperationHandler(ClientOperationHandler):
def _readOnly(self, *args, **kw): raise NotReadyError('read-only access')
abortTransaction = _readOnly
askStoreTransaction = _readOnly
askVoteTransaction = _readOnly
askStoreObject = _readOnly
askFinalTID = _readOnly
# askObjectUndoSerial is used in undo() but itself is read-only query
askCheckCurrentSerial = _readOnly # takes write lock & is only used when going to commit
......@@ -48,7 +48,10 @@ class IdentificationHandler(EventHandler):
raise BrokenNodeDisallowedError
# choose the handler according to the node type
if node_type == NodeTypes.CLIENT:
handler = ClientOperationHandler # NOTE
if app.dm.getBackupTID():
handler = ClientROOperationHandler
else:
handler = ClientOperationHandler
if node is None:
node = app.nm.createClient(uuid=uuid)
elif node.isConnected():
......
......@@ -72,7 +72,6 @@ class Partition(object):
if hasattr(self, x)),
id(self))
# NOTE
class Replicator(object):
current_node = None
......
......@@ -28,13 +28,14 @@ BaseApplication
.pt ? PartitionTable
.checker Checker
.checker Checker # checks sha1([]tid -- XXX only tid list, not other metadata & data)
.replicator Replicator
.listening_conn ListeningConnection
.master_conn
.master_node
# (queued events are executed at some txn boundaries & locks)
.event_queue deque (key, callable, msg_id, conn, args)
.event_queue_dict {} key -> count(.event_queue, key)
......
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