Commit 5308866e authored by Grégory Wisniewski's avatar Grégory Wisniewski

Define some instance variables in __init__ method. Fix a bug, conflicting object

was not store in a thread-safe space.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@983 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f33305d5
......@@ -40,6 +40,7 @@ class BootstrapManager(EventHandler):
self.name = name
self.num_replicas = None
self.num_partitions = None
self.curent = None
def connectionCompleted(self, conn):
EventHandler.connectionCompleted(self, conn)
......
......@@ -175,6 +175,23 @@ class ThreadContext(object):
_threads_dict = {}
def __init__(self):
self.tid = None
self.txn = None
self.txn_voted = False
self.txn_finished = False
self.txn_info = 0
self.history = None
self.data_dict = {}
self.node_tids = {}
self.node_ready = False
self.conflict_serial = 0
self.asked_object = 0
self.object_stored_counter = 0
self.voted_counter = 0
self.object_stored = 0
self.queue = Queue(5)
def __getThreadData(self):
thread_id = get_ident()
try:
......@@ -221,6 +238,7 @@ class Application(object):
# Start polling thread
self.poll_thread = ThreadedPoll(em)
# Internal Attributes common to all thread
self._db = None
self.name = name
self.em = em
self.connector_handler = getConnectorHandler(connector)
......@@ -685,7 +703,7 @@ class Application(object):
# previous node which already store data as it would be resent
# again if conflict is resolved or txn will be aborted
del self.local_var.data_dict[oid]
self.conflict_serial = self.local_var.object_stored[1]
self.local_var.conflict_serial = self.local_var.object_stored[1]
raise NEOStorageConflictError
# increase counter so that we know if a node has stored the object or not
self.local_var.object_stored_counter += 1
......@@ -1032,7 +1050,7 @@ class Application(object):
return self.local_var.tid
def getConflictSerial(self):
return self.conflict_serial
return self.local_var.conflict_serial
def setTransactionFinished(self):
self.local_var.txn_finished = True
......
......@@ -47,10 +47,11 @@ from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICAT
class EventHandler(object):
"""This class handles events."""
def __init__(self, app):
self.app = app
self.initPacketDispatchTable()
self.initErrorDispatchTable()
self.packet_dispatch_table = self.initPacketDispatchTable()
self.error_dispatch_table = self.initErrorDispatchTable()
def connectionStarted(self, conn):
"""Called when a connection is started."""
......@@ -445,10 +446,11 @@ class EventHandler(object):
d[ANSWER_CLUSTER_STATE] = self.handleAnswerClusterState
d[NOTIFY_CLUSTER_INFORMATION] = self.handleNotifyClusterInformation
self.packet_dispatch_table = d
return d
def initErrorDispatchTable(self):
d = {}
d[NO_ERROR_CODE] = self.handleNoError
d[NOT_READY_CODE] = self.handleNotReady
d[OID_NOT_FOUND_CODE] = self.handleOidNotFound
......@@ -459,4 +461,5 @@ class EventHandler(object):
d[BROKEN_NODE_DISALLOWED_CODE] = self.handleBrokenNodeDisallowedError
d[INTERNAL_ERROR_CODE] = self.handleInternalError
self.error_dispatch_table = d
return d
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