Commit 436e3a5c authored by Vincent Pelletier's avatar Vincent Pelletier

Stop defining and using default "NEO" logger.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2371 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 66486399
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
import logging as logging_std import logging as logging_std
# default logger # "logging" is available here only once setupLog has been called.
logging = logging_std.getLogger('NEO')
PREFIX = '%(asctime)s %(levelname)-9s %(name)-10s' PREFIX = '%(asctime)s %(levelname)-9s %(name)-10s'
SUFFIX = ' [%(module)14s:%(lineno)3d] %(message)s' SUFFIX = ' [%(module)14s:%(lineno)3d] %(message)s'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.node import NodeManager from neo.node import NodeManager
from neo.event import EventManager from neo.event import EventManager
...@@ -68,7 +68,7 @@ class Application(object): ...@@ -68,7 +68,7 @@ class Application(object):
self.server = config.getBind() self.server = config.getBind()
self.master_addresses = config.getMasters() self.master_addresses = config.getMasters()
logging.debug('IP address is %s, port is %d', *(self.server)) neo.logging.debug('IP address is %s, port is %d', *(self.server))
# The partition table is initialized after getting the number of # The partition table is initialized after getting the number of
# partitions. # partitions.
...@@ -105,7 +105,7 @@ class Application(object): ...@@ -105,7 +105,7 @@ class Application(object):
while True: while True:
self.em.poll(1) self.em.poll(1)
except PrimaryFailure: except PrimaryFailure:
logging.error('primary master is down') neo.logging.error('primary master is down')
def connectToPrimary(self): def connectToPrimary(self):
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.handler import EventHandler from neo.handler import EventHandler
from neo import protocol from neo import protocol
...@@ -42,7 +42,7 @@ class AdminEventHandler(EventHandler): ...@@ -42,7 +42,7 @@ class AdminEventHandler(EventHandler):
"""This class deals with events for administrating cluster.""" """This class deals with events for administrating cluster."""
def askPartitionList(self, conn, min_offset, max_offset, uuid): def askPartitionList(self, conn, min_offset, max_offset, uuid):
logging.info("ask partition list from %s to %s for %s" % neo.logging.info("ask partition list from %s to %s for %s" %
(min_offset, max_offset, dump(uuid))) (min_offset, max_offset, dump(uuid)))
app = self.app app = self.app
# check we have one pt otherwise ask it to PMN # check we have one pt otherwise ask it to PMN
...@@ -61,7 +61,7 @@ class AdminEventHandler(EventHandler): ...@@ -61,7 +61,7 @@ class AdminEventHandler(EventHandler):
def askNodeList(self, conn, node_type): def askNodeList(self, conn, node_type):
logging.info("ask node list for %s" %(node_type)) neo.logging.info("ask node list for %s" %(node_type))
def node_filter(n): def node_filter(n):
return n.getType() is node_type return n.getType() is node_type
node_list = self.app.nm.getList(node_filter) node_list = self.app.nm.getList(node_filter)
...@@ -70,7 +70,7 @@ class AdminEventHandler(EventHandler): ...@@ -70,7 +70,7 @@ class AdminEventHandler(EventHandler):
conn.answer(p) conn.answer(p)
def setNodeState(self, conn, uuid, state, modify_partition_table): def setNodeState(self, conn, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s" %(dump(uuid), state)) neo.logging.info("set node state for %s-%s" %(dump(uuid), state))
node = self.app.nm.getByUUID(uuid) node = self.app.nm.getByUUID(uuid)
if node is None: if node is None:
raise protocol.ProtocolError('invalid uuid') raise protocol.ProtocolError('invalid uuid')
...@@ -144,7 +144,7 @@ class MasterEventHandler(EventHandler): ...@@ -144,7 +144,7 @@ class MasterEventHandler(EventHandler):
def answerNodeInformation(self, conn): def answerNodeInformation(self, conn):
# XXX: This will no more exists when the initialization module will be # XXX: This will no more exists when the initialization module will be
# implemented for factorize code (as done for bootstrap) # implemented for factorize code (as done for bootstrap)
logging.debug("answerNodeInformation") neo.logging.debug("answerNodeInformation")
def notifyPartitionChanges(self, conn, ptid, cell_list): def notifyPartitionChanges(self, conn, ptid, cell_list):
self.app.pt.update(ptid, cell_list, self.app.nm) self.app.pt.update(ptid, cell_list, self.app.nm)
...@@ -176,12 +176,12 @@ class MasterRequestEventHandler(EventHandler): ...@@ -176,12 +176,12 @@ class MasterRequestEventHandler(EventHandler):
client_conn.answer(packet) client_conn.answer(packet)
def answerClusterState(self, conn, state): def answerClusterState(self, conn, state):
logging.info("answerClusterState for a conn") neo.logging.info("answerClusterState for a conn")
self.app.cluster_state = state self.app.cluster_state = state
self._answerNeoCTL(conn, Packets.AnswerClusterState(state)) self._answerNeoCTL(conn, Packets.AnswerClusterState(state))
def answerPartitionTable(self, conn, ptid, row_list): def answerPartitionTable(self, conn, ptid, row_list):
logging.info("answerPartitionTable for a conn") neo.logging.info("answerPartitionTable for a conn")
client_conn, kw = self.app.dispatcher.pop(conn.getPeerId()) client_conn, kw = self.app.dispatcher.pop(conn.getPeerId())
# sent client the partition table # sent client the partition table
self.app.sendPartitionTable(client_conn) self.app.sendPartitionTable(client_conn)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from time import sleep from time import sleep
from neo.handler import EventHandler from neo.handler import EventHandler
...@@ -106,7 +106,7 @@ class BootstrapManager(EventHandler): ...@@ -106,7 +106,7 @@ class BootstrapManager(EventHandler):
conn.close() conn.close()
return return
logging.info('connected to a primary master node') neo.logging.info('connected to a primary master node')
conn.ask(Packets.RequestIdentification(self.node_type, conn.ask(Packets.RequestIdentification(self.node_type,
self.uuid, self.server, self.name)) self.uuid, self.server, self.name))
...@@ -120,7 +120,7 @@ class BootstrapManager(EventHandler): ...@@ -120,7 +120,7 @@ class BootstrapManager(EventHandler):
if self.uuid != your_uuid: if self.uuid != your_uuid:
# got an uuid from the primary master # got an uuid from the primary master
self.uuid = your_uuid self.uuid = your_uuid
logging.info('Got a new UUID : %s' % dump(self.uuid)) neo.logging.info('Got a new UUID : %s' % dump(self.uuid))
conn.setUUID(uuid) conn.setUUID(uuid)
def getPrimaryConnection(self, connector_handler): def getPrimaryConnection(self, connector_handler):
...@@ -128,7 +128,7 @@ class BootstrapManager(EventHandler): ...@@ -128,7 +128,7 @@ class BootstrapManager(EventHandler):
Primary lookup/connection process. Primary lookup/connection process.
Returns when the connection is made. Returns when the connection is made.
""" """
logging.info('connecting to a primary master node') neo.logging.info('connecting to a primary master node')
em, nm = self.app.em, self.app.nm em, nm = self.app.em, self.app.nm
index = 0 index = 0
self.current = nm.getMasterList()[0] self.current = nm.getMasterList()[0]
......
...@@ -163,7 +163,7 @@ class Storage(BaseStorage.BaseStorage, ...@@ -163,7 +163,7 @@ class Storage(BaseStorage.BaseStorage,
def pack(self, t, referencesf, gc=False): def pack(self, t, referencesf, gc=False):
if gc: if gc:
logging.warning('Garbage Collection is not available in NEO, ' neo.logging.warning('Garbage Collection is not available in NEO, '
'please use an external tool. Packing without GC.') 'please use an external tool. Packing without GC.')
self.app.pack(t) self.app.pack(t)
......
...@@ -29,7 +29,7 @@ from persistent.TimeStamp import TimeStamp ...@@ -29,7 +29,7 @@ from persistent.TimeStamp import TimeStamp
from neo import setupLog from neo import setupLog
setupLog('CLIENT', verbose=True) setupLog('CLIENT', verbose=True)
from neo import logging import neo
from neo.protocol import NodeTypes, Packets, INVALID_PARTITION, ZERO_TID from neo.protocol import NodeTypes, Packets, INVALID_PARTITION, ZERO_TID
from neo.event import EventManager from neo.event import EventManager
from neo.util import makeChecksum as real_makeChecksum, dump from neo.util import makeChecksum as real_makeChecksum, dump
...@@ -317,7 +317,7 @@ class Application(object): ...@@ -317,7 +317,7 @@ class Application(object):
""" """
Lookup for the current primary master node Lookup for the current primary master node
""" """
logging.debug('connecting to primary master...') neo.logging.debug('connecting to primary master...')
ready = False ready = False
nm = self.nm nm = self.nm
queue = self.local_var.queue queue = self.local_var.queue
...@@ -349,7 +349,7 @@ class Application(object): ...@@ -349,7 +349,7 @@ class Application(object):
# Query for primary master node # Query for primary master node
if conn.getConnector() is None: if conn.getConnector() is None:
# This happens if a connection could not be established. # This happens if a connection could not be established.
logging.error('Connection to master node %s failed', neo.logging.error('Connection to master node %s failed',
self.trying_master_node) self.trying_master_node)
continue continue
try: try:
...@@ -361,14 +361,15 @@ class Application(object): ...@@ -361,14 +361,15 @@ class Application(object):
# If we reached the primary master node, mark as connected # If we reached the primary master node, mark as connected
connected = self.primary_master_node is not None and \ connected = self.primary_master_node is not None and \
self.primary_master_node is self.trying_master_node self.primary_master_node is self.trying_master_node
logging.info('Connected to %s' % (self.primary_master_node, )) neo.logging.info('Connected to %s' % (self.primary_master_node, ))
try: try:
ready = self.identifyToPrimaryNode(conn) ready = self.identifyToPrimaryNode(conn)
except ConnectionClosed: except ConnectionClosed:
logging.error('Connection to %s lost', self.trying_master_node) neo.logging.error('Connection to %s lost',
self.trying_master_node)
self.primary_master_node = None self.primary_master_node = None
continue continue
logging.info("Connected and ready") neo.logging.info("Connected and ready")
return conn return conn
def identifyToPrimaryNode(self, conn): def identifyToPrimaryNode(self, conn):
...@@ -377,7 +378,7 @@ class Application(object): ...@@ -377,7 +378,7 @@ class Application(object):
Might raise ConnectionClosed so that the new primary can be Might raise ConnectionClosed so that the new primary can be
looked-up again. looked-up again.
""" """
logging.info('Initializing from master') neo.logging.info('Initializing from master')
queue = self.local_var.queue queue = self.local_var.queue
# Identify to primary master and request initial data # Identify to primary master and request initial data
while conn.getUUID() is None: while conn.getUUID() is None:
...@@ -490,7 +491,7 @@ class Application(object): ...@@ -490,7 +491,7 @@ class Application(object):
self.local_var.asked_object = 0 self.local_var.asked_object = 0
packet = Packets.AskObject(oid, serial, tid) packet = Packets.AskObject(oid, serial, tid)
for cell in cell_list: for cell in cell_list:
logging.debug('trying to load %s at %s before %s from %s', neo.logging.debug('trying to load %s at %s before %s from %s',
dump(oid), dump(serial), dump(tid), dump(cell.getUUID())) dump(oid), dump(serial), dump(tid), dump(cell.getUUID()))
conn = self.cp.getConnForCell(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
...@@ -506,13 +507,13 @@ class Application(object): ...@@ -506,13 +507,13 @@ class Application(object):
= self.local_var.asked_object = self.local_var.asked_object
if noid != oid: if noid != oid:
# Oops, try with next node # Oops, try with next node
logging.error('got wrong oid %s instead of %s from node %s', neo.logging.error('got wrong oid %s instead of %s from node ' \
noid, dump(oid), cell.getAddress()) '%s', noid, dump(oid), cell.getAddress())
self.local_var.asked_object = -1 self.local_var.asked_object = -1
continue continue
elif checksum != makeChecksum(data): elif checksum != makeChecksum(data):
# Check checksum. # Check checksum.
logging.error('wrong checksum from node %s for oid %s', neo.logging.error('wrong checksum from node %s for oid %s',
cell.getAddress(), dump(oid)) cell.getAddress(), dump(oid))
self.local_var.asked_object = -1 self.local_var.asked_object = -1
continue continue
...@@ -553,7 +554,7 @@ class Application(object): ...@@ -553,7 +554,7 @@ class Application(object):
self._cache_lock_acquire() self._cache_lock_acquire()
try: try:
if oid in self.mq_cache: if oid in self.mq_cache:
logging.debug('load oid %s is cached', dump(oid)) neo.logging.debug('load oid %s is cached', dump(oid))
serial, data = self.mq_cache[oid] serial, data = self.mq_cache[oid]
return data, serial return data, serial
finally: finally:
...@@ -577,7 +578,7 @@ class Application(object): ...@@ -577,7 +578,7 @@ class Application(object):
def loadSerial(self, oid, serial): def loadSerial(self, oid, serial):
"""Load an object for a given oid and serial.""" """Load an object for a given oid and serial."""
# Do not try in cache as it manages only up-to-date object # Do not try in cache as it manages only up-to-date object
logging.debug('loading %s at %s', dump(oid), dump(serial)) neo.logging.debug('loading %s at %s', dump(oid), dump(serial))
return self._load(oid, serial=serial)[0] return self._load(oid, serial=serial)[0]
...@@ -585,7 +586,7 @@ class Application(object): ...@@ -585,7 +586,7 @@ class Application(object):
def loadBefore(self, oid, tid): def loadBefore(self, oid, tid):
"""Load an object for a given oid before tid committed.""" """Load an object for a given oid before tid committed."""
# Do not try in cache as it manages only up-to-date object # Do not try in cache as it manages only up-to-date object
logging.debug('loading %s before %s', dump(oid), dump(tid)) neo.logging.debug('loading %s before %s', dump(oid), dump(tid))
return self._load(oid, tid=tid) return self._load(oid, tid=tid)
...@@ -611,7 +612,7 @@ class Application(object): ...@@ -611,7 +612,7 @@ class Application(object):
"""Store object.""" """Store object."""
if transaction is not self.local_var.txn: if transaction is not self.local_var.txn:
raise StorageTransactionError(self, transaction) raise StorageTransactionError(self, transaction)
logging.debug('storing oid %s serial %s', neo.logging.debug('storing oid %s serial %s',
dump(oid), dump(serial)) dump(oid), dump(serial))
self._store(oid, serial, data) self._store(oid, serial, data)
return None return None
...@@ -699,8 +700,9 @@ class Application(object): ...@@ -699,8 +700,9 @@ class Application(object):
new_data = tryToResolveConflict(oid, conflict_serial, serial, new_data = tryToResolveConflict(oid, conflict_serial, serial,
data) data)
if new_data is not None: if new_data is not None:
logging.info('Conflict resolution succeed for %r:%r with %r', neo.logging.info('Conflict resolution succeed for ' \
dump(oid), dump(serial), dump(conflict_serial)) '%r:%r with %r', dump(oid), dump(serial),
dump(conflict_serial))
# Mark this conflict as resolved # Mark this conflict as resolved
resolved_serial_set.update(conflict_serial_dict.pop(oid)) resolved_serial_set.update(conflict_serial_dict.pop(oid))
# Try to store again # Try to store again
...@@ -708,10 +710,11 @@ class Application(object): ...@@ -708,10 +710,11 @@ class Application(object):
append(oid) append(oid)
resolved = True resolved = True
else: else:
logging.info('Conflict resolution failed for %r:%r with %r', neo.logging.info('Conflict resolution failed for ' \
dump(oid), dump(serial), dump(conflict_serial)) '%r:%r with %r', dump(oid), dump(serial),
dump(conflict_serial))
else: else:
logging.info('Conflict reported for %r:%r with later ' \ neo.logging.info('Conflict reported for %r:%r with later ' \
'transaction %r , cannot resolve conflict.', dump(oid), 'transaction %r , cannot resolve conflict.', dump(oid),
dump(serial), dump(conflict_serial)) dump(serial), dump(conflict_serial))
if not resolved: if not resolved:
...@@ -779,7 +782,7 @@ class Application(object): ...@@ -779,7 +782,7 @@ class Application(object):
local_var.data_list) local_var.data_list)
add_involved_nodes = self.local_var.involved_nodes.add add_involved_nodes = self.local_var.involved_nodes.add
for cell in self._getCellListForTID(tid, writable=True): for cell in self._getCellListForTID(tid, writable=True):
logging.debug("voting object %s %s", cell.getAddress(), neo.logging.debug("voting object %s %s", cell.getAddress(),
cell.getState()) cell.getState())
conn = self.cp.getConnForCell(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
...@@ -824,7 +827,7 @@ class Application(object): ...@@ -824,7 +827,7 @@ class Application(object):
try: try:
conn.notify(p) conn.notify(p)
except: except:
logging.error('Exception in tpc_abort while notifying ' \ neo.logging.error('Exception in tpc_abort while notifying ' \
'storage node %r of abortion, ignoring.', conn, exc_info=1) 'storage node %r of abortion, ignoring.', conn, exc_info=1)
# Just wait for responses to arrive. If any leads to an exception, # Just wait for responses to arrive. If any leads to an exception,
...@@ -837,7 +840,7 @@ class Application(object): ...@@ -837,7 +840,7 @@ class Application(object):
try: try:
_waitAnyMessage() _waitAnyMessage()
except: except:
logging.error('Exception in tpc_abort while handling ' \ neo.logging.error('Exception in tpc_abort while handling ' \
'pending answers, ignoring.', exc_info=1) 'pending answers, ignoring.', exc_info=1)
self.local_var.clear() self.local_var.clear()
...@@ -906,7 +909,7 @@ class Application(object): ...@@ -906,7 +909,7 @@ class Application(object):
continue continue
except NEOStorageNotFoundError: except NEOStorageNotFoundError:
# Tid not found, try with next node # Tid not found, try with next node
logging.warning('Transaction %s was not found on node %s', neo.logging.warning('Transaction %s was not found on node %s',
dump(undone_tid), self.nm.getByAddress(conn.getAddress())) dump(undone_tid), self.nm.getByAddress(conn.getAddress()))
continue continue
...@@ -1022,7 +1025,7 @@ class Application(object): ...@@ -1022,7 +1025,7 @@ class Application(object):
update(tid_list) update(tid_list)
ordered_tids = list(ordered_tids) ordered_tids = list(ordered_tids)
ordered_tids.sort(reverse=True) ordered_tids.sort(reverse=True)
logging.debug("UndoLog tids %s", [dump(x) for x in ordered_tids]) neo.logging.debug("UndoLog tids %s", [dump(x) for x in ordered_tids])
# For each transaction, get info # For each transaction, get info
undo_info = [] undo_info = []
append = undo_info.append append = undo_info.append
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.client.handlers import BaseHandler, AnswerBaseHandler from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.pt import MTPartitionTable as PartitionTable from neo.pt import MTPartitionTable as PartitionTable
...@@ -43,7 +43,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler): ...@@ -43,7 +43,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
if your_uuid is None: if your_uuid is None:
raise ProtocolError('No UUID supplied') raise ProtocolError('No UUID supplied')
app.uuid = your_uuid app.uuid = your_uuid
logging.info('Got an UUID: %s', dump(app.uuid)) neo.logging.info('Got an UUID: %s', dump(app.uuid))
node = app.nm.getByAddress(conn.getAddress()) node = app.nm.getByAddress(conn.getAddress())
conn.setUUID(uuid) conn.setUUID(uuid)
...@@ -66,7 +66,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler): ...@@ -66,7 +66,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
if primary_node is None: if primary_node is None:
# I don't know such a node. Probably this information # I don't know such a node. Probably this information
# is old. So ignore it. # is old. So ignore it.
logging.warning('Unknown primary master UUID: %s. ' \ neo.logging.warning('Unknown primary master UUID: %s. ' \
'Ignoring.' % dump(primary_uuid)) 'Ignoring.' % dump(primary_uuid))
else: else:
app.primary_master_node = primary_node app.primary_master_node = primary_node
...@@ -94,7 +94,7 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -94,7 +94,7 @@ class PrimaryNotificationsHandler(BaseHandler):
def connectionClosed(self, conn): def connectionClosed(self, conn):
app = self.app app = self.app
logging.critical("connection to primary master node closed") neo.logging.critical("connection to primary master node closed")
conn.close() conn.close()
app.master_conn = None app.master_conn = None
app.primary_master_node = None app.primary_master_node = None
...@@ -104,7 +104,7 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -104,7 +104,7 @@ class PrimaryNotificationsHandler(BaseHandler):
app = self.app app = self.app
if app.master_conn is not None: if app.master_conn is not None:
assert conn is app.master_conn assert conn is app.master_conn
logging.critical("connection timeout to primary master node " \ neo.logging.critical("connection timeout to primary master node " \
"expired") "expired")
BaseHandler.timeoutExpired(self, conn) BaseHandler.timeoutExpired(self, conn)
...@@ -112,11 +112,11 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -112,11 +112,11 @@ class PrimaryNotificationsHandler(BaseHandler):
app = self.app app = self.app
if app.master_conn is not None: if app.master_conn is not None:
assert conn is app.master_conn assert conn is app.master_conn
logging.critical("primary master node is broken") neo.logging.critical("primary master node is broken")
BaseHandler.peerBroken(self, conn) BaseHandler.peerBroken(self, conn)
def stopOperation(self, conn): def stopOperation(self, conn):
logging.critical("master node ask to stop operation") neo.logging.critical("master node ask to stop operation")
def invalidateObjects(self, conn, tid, oid_list): def invalidateObjects(self, conn, tid, oid_list):
app = self.app app = self.app
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
from ZODB.TimeStamp import TimeStamp from ZODB.TimeStamp import TimeStamp
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from neo import logging import neo
from neo.client.handlers import BaseHandler, AnswerBaseHandler from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.protocol import NodeTypes, ProtocolError, LockState from neo.protocol import NodeTypes, ProtocolError, LockState
from neo.util import dump from neo.util import dump
...@@ -74,7 +74,7 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -74,7 +74,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
local_var = self.app.local_var local_var = self.app.local_var
object_stored_counter_dict = local_var.object_stored_counter_dict[oid] object_stored_counter_dict = local_var.object_stored_counter_dict[oid]
if conflicting: if conflicting:
logging.info('%r report a conflict for %r with %r', conn, neo.logging.info('%r report a conflict for %r with %r', conn,
dump(oid), dump(serial)) dump(oid), dump(serial))
conflict_serial_dict = local_var.conflict_serial_dict conflict_serial_dict = local_var.conflict_serial_dict
if serial in object_stored_counter_dict: if serial in object_stored_counter_dict:
...@@ -138,8 +138,8 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -138,8 +138,8 @@ class StorageAnswersHandler(AnswerBaseHandler):
raise ConflictError, 'Lock wait timeout for oid %s on %r' % ( raise ConflictError, 'Lock wait timeout for oid %s on %r' % (
dump(oid), conn) dump(oid), conn)
elif status == LockState.GRANTED: elif status == LockState.GRANTED:
logging.info('Store of oid %s was successful, but after timeout.', neo.logging.info('Store of oid %s was successful, but after ' \
dump(oid)) 'timeout.', dump(oid))
# XXX: Not sure what to do in this case yet, for now do nothing. # XXX: Not sure what to do in this case yet, for now do nothing.
else: else:
# Nobody has the lock, although we asked storage to lock. This # Nobody has the lock, although we asked storage to lock. This
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from threading import Thread, Event from threading import Thread, Event
from neo import logging import neo
class ThreadedPoll(Thread): class ThreadedPoll(Thread):
"""Polling thread.""" """Polling thread."""
...@@ -24,7 +24,7 @@ class ThreadedPoll(Thread): ...@@ -24,7 +24,7 @@ class ThreadedPoll(Thread):
# Garbage collector hint: # Garbage collector hint:
# Prevent logging module from being garbage-collected as it is needed for # Prevent logging module from being garbage-collected as it is needed for
# run method to cleanly exit. # run method to cleanly exit.
logging = logging neo = neo
def __init__(self, em, **kw): def __init__(self, em, **kw):
Thread.__init__(self, **kw) Thread.__init__(self, **kw)
...@@ -39,8 +39,8 @@ class ThreadedPoll(Thread): ...@@ -39,8 +39,8 @@ class ThreadedPoll(Thread):
try: try:
self.em.poll() self.em.poll()
except: except:
self.logging.error('poll raised, retrying', exc_info=1) self.neo.logging.error('poll raised, retrying', exc_info=1)
self.logging.debug('Threaded poll stopped') self.neo.logging.debug('Threaded poll stopped')
def stop(self): def stop(self):
self._stop.set() self._stop.set()
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.locking import RLock from neo.locking import RLock
from neo.protocol import NodeTypes, Packets from neo.protocol import NodeTypes, Packets
from neo.connection import MTClientConnection, ConnectionClosed from neo.connection import MTClientConnection, ConnectionClosed
...@@ -61,7 +61,8 @@ class ConnectionPool(object): ...@@ -61,7 +61,8 @@ class ConnectionPool(object):
# Loop until a connection is obtained. # Loop until a connection is obtained.
while True: while True:
logging.debug('trying to connect to %s - %s', node, node.getState()) neo.logging.debug('trying to connect to %s - %s', node,
node.getState())
app.setNodeReady() app.setNodeReady()
conn = MTClientConnection(app.em, conn = MTClientConnection(app.em,
app.storage_event_handler, addr, app.storage_event_handler, addr,
...@@ -71,7 +72,7 @@ class ConnectionPool(object): ...@@ -71,7 +72,7 @@ class ConnectionPool(object):
try: try:
if conn.getConnector() is None: if conn.getConnector() is None:
# This happens, if a connection could not be established. # This happens, if a connection could not be established.
logging.error('Connection to %r failed', node) neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node) self.notifyFailure(node)
return None return None
...@@ -85,15 +86,15 @@ class ConnectionPool(object): ...@@ -85,15 +86,15 @@ class ConnectionPool(object):
app._waitMessage(conn, msg_id, app._waitMessage(conn, msg_id,
handler=app.storage_bootstrap_handler) handler=app.storage_bootstrap_handler)
except ConnectionClosed: except ConnectionClosed:
logging.error('Connection to %r failed', node) neo.logging.error('Connection to %r failed', node)
self.notifyFailure(node) self.notifyFailure(node)
return None return None
if app.isNodeReady(): if app.isNodeReady():
logging.info('Connected %r', node) neo.logging.info('Connected %r', node)
return conn return conn
else: else:
logging.info('%r not ready', node) neo.logging.info('%r not ready', node)
self.notifyFailure(node) self.notifyFailure(node)
return None return None
...@@ -108,8 +109,8 @@ class ConnectionPool(object): ...@@ -108,8 +109,8 @@ class ConnectionPool(object):
not self.app.dispatcher.registered(conn): not self.app.dispatcher.registered(conn):
del self.connection_dict[conn.getUUID()] del self.connection_dict[conn.getUUID()]
conn.close() conn.close()
logging.debug('_dropConnections : connection to storage ' \ neo.logging.debug('_dropConnections : connection to ' \
'node %s:%d closed', *(conn.getAddress())) 'storage node %s:%d closed', *(conn.getAddress()))
if len(self.connection_dict) <= self.max_pool_size: if len(self.connection_dict) <= self.max_pool_size:
break break
finally: finally:
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from time import time from time import time
from neo import logging import neo
from neo.locking import RLock from neo.locking import RLock
from neo.protocol import PacketMalformedError, Packets, ParserState from neo.protocol import PacketMalformedError, Packets, ParserState
...@@ -62,9 +62,9 @@ def lockCheckWrapper(func): ...@@ -62,9 +62,9 @@ def lockCheckWrapper(func):
def wrapper(self, *args, **kw): def wrapper(self, *args, **kw):
if not self._lock._is_owned(): if not self._lock._is_owned():
import traceback import traceback
logging.warning('%s called on %s instance without being locked.' \ neo.logging.warning('%s called on %s instance without being ' \
' Stack:\n%s', func.func_code.co_name, self.__class__.__name__, 'locked. Stack:\n%s', func.func_code.co_name,
''.join(traceback.format_stack())) self.__class__.__name__, ''.join(traceback.format_stack()))
# Call anyway # Call anyway
return func(self, *args, **kw) return func(self, *args, **kw)
return wrapper return wrapper
...@@ -173,7 +173,7 @@ class HandlerSwitcher(object): ...@@ -173,7 +173,7 @@ class HandlerSwitcher(object):
if klass and isinstance(packet, klass) or packet.isError(): if klass and isinstance(packet, klass) or packet.isError():
handler.packetReceived(connection, packet) handler.packetReceived(connection, packet)
else: else:
logging.error('Unexpected answer %r in %r', packet, connection) neo.logging.error('Unexpected answer %r in %r', packet, connection)
notification = Packets.Notify('Unexpected answer: %r' % packet) notification = Packets.Notify('Unexpected answer: %r' % packet)
connection.notify(notification) connection.notify(notification)
connection.abort() connection.abort()
...@@ -181,7 +181,7 @@ class HandlerSwitcher(object): ...@@ -181,7 +181,7 @@ class HandlerSwitcher(object):
# apply a pending handler if no more answers are pending # apply a pending handler if no more answers are pending
while len(self._pending) > 1 and not self._pending[0][0]: while len(self._pending) > 1 and not self._pending[0][0]:
del self._pending[0] del self._pending[0]
logging.debug('Apply handler %r on %r', self._pending[0][1], neo.logging.debug('Apply handler %r on %r', self._pending[0][1],
connection) connection)
if timeout == self._next_timeout: if timeout == self._next_timeout:
self._updateNextTimeout() self._updateNextTimeout()
...@@ -279,12 +279,12 @@ class BaseConnection(object): ...@@ -279,12 +279,12 @@ class BaseConnection(object):
if handlers.isPending(): if handlers.isPending():
msg_id = handlers.checkTimeout(self, t) msg_id = handlers.checkTimeout(self, t)
if msg_id is not None: if msg_id is not None:
logging.info('timeout for %r with %r', msg_id, self) neo.logging.info('timeout for %r with %r', msg_id, self)
self.close() self.close()
self.getHandler().timeoutExpired(self) self.getHandler().timeoutExpired(self)
elif self._timeout.hardExpired(t): elif self._timeout.hardExpired(t):
# critical time reach or pong not received, abort # critical time reach or pong not received, abort
logging.info('timeout with %r', self) neo.logging.info('timeout with %r', self)
self.notify(Packets.Notify('Timeout')) self.notify(Packets.Notify('Timeout'))
self.abort() self.abort()
self.getHandler().timeoutExpired(self) self.getHandler().timeoutExpired(self)
...@@ -338,9 +338,9 @@ class BaseConnection(object): ...@@ -338,9 +338,9 @@ class BaseConnection(object):
def setHandler(self, handler): def setHandler(self, handler):
if self._handlers.setHandler(handler): if self._handlers.setHandler(handler):
logging.debug('Set handler %r on %r', handler, self) neo.logging.debug('Set handler %r on %r', handler, self)
else: else:
logging.debug('Delay handler %r on %r', handler, self) neo.logging.debug('Delay handler %r on %r', handler, self)
def getEventManager(self): def getEventManager(self):
return self.em return self.em
...@@ -379,7 +379,7 @@ class ListeningConnection(BaseConnection): ...@@ -379,7 +379,7 @@ class ListeningConnection(BaseConnection):
"""A listen connection.""" """A listen connection."""
def __init__(self, event_manager, handler, addr, connector, **kw): def __init__(self, event_manager, handler, addr, connector, **kw):
logging.debug('listening to %s:%d', *addr) neo.logging.debug('listening to %s:%d', *addr)
BaseConnection.__init__(self, event_manager, handler, BaseConnection.__init__(self, event_manager, handler,
addr=addr, connector=connector) addr=addr, connector=connector)
self.connector.makeListeningConnection(addr) self.connector.makeListeningConnection(addr)
...@@ -388,7 +388,7 @@ class ListeningConnection(BaseConnection): ...@@ -388,7 +388,7 @@ class ListeningConnection(BaseConnection):
def readable(self): def readable(self):
try: try:
new_s, addr = self.connector.getNewConnection() new_s, addr = self.connector.getNewConnection()
logging.debug('accepted a connection from %s:%d', *addr) neo.logging.debug('accepted a connection from %s:%d', *addr)
handler = self.getHandler() handler = self.getHandler()
new_conn = ServerConnection(self.getEventManager(), handler, new_conn = ServerConnection(self.getEventManager(), handler,
connector=new_s, addr=addr) connector=new_s, addr=addr)
...@@ -451,7 +451,7 @@ class Connection(BaseConnection): ...@@ -451,7 +451,7 @@ class Connection(BaseConnection):
return next_id return next_id
def close(self): def close(self):
logging.debug('closing a connector for %r', self) neo.logging.debug('closing a connector for %r', self)
BaseConnection.close(self) BaseConnection.close(self)
if self._on_close is not None: if self._on_close is not None:
self._on_close() self._on_close()
...@@ -462,7 +462,7 @@ class Connection(BaseConnection): ...@@ -462,7 +462,7 @@ class Connection(BaseConnection):
def abort(self): def abort(self):
"""Abort dealing with this connection.""" """Abort dealing with this connection."""
logging.debug('aborting a connector for %r', self) neo.logging.debug('aborting a connector for %r', self)
self.aborted = True self.aborted = True
def writable(self): def writable(self):
...@@ -548,16 +548,17 @@ class Connection(BaseConnection): ...@@ -548,16 +548,17 @@ class Connection(BaseConnection):
except ConnectorConnectionClosedException: except ConnectorConnectionClosedException:
# connection resetted by peer, according to the man, this error # connection resetted by peer, according to the man, this error
# should not occurs but it seems it's false # should not occurs but it seems it's false
logging.debug('Connection reset by peer: %r', self.connector) neo.logging.debug('Connection reset by peer: %r', self.connector)
self._closure() self._closure()
except: except:
logging.debug('Unknown connection error: %r', self.connector) neo.logging.debug('Unknown connection error: %r', self.connector)
self._closure() self._closure()
# unhandled connector exception # unhandled connector exception
raise raise
else: else:
if not data: if not data:
logging.debug('Connection %r closed in recv', self.connector) neo.logging.debug('Connection %r closed in recv',
self.connector)
self._closure() self._closure()
return return
self.read_buf.append(data) self.read_buf.append(data)
...@@ -574,16 +575,17 @@ class Connection(BaseConnection): ...@@ -574,16 +575,17 @@ class Connection(BaseConnection):
pass pass
except ConnectorConnectionClosedException: except ConnectorConnectionClosedException:
# connection resetted by peer # connection resetted by peer
logging.debug('Connection reset by peer: %r', self.connector) neo.logging.debug('Connection reset by peer: %r', self.connector)
self._closure() self._closure()
except: except:
logging.debug('Unknown connection error: %r', self.connector) neo.logging.debug('Unknown connection error: %r', self.connector)
# unhandled connector exception # unhandled connector exception
self._closure() self._closure()
raise raise
else: else:
if not n: if not n:
logging.debug('Connection %r closed in send', self.connector) neo.logging.debug('Connection %r closed in send',
self.connector)
self._closure() self._closure()
return return
if n == len(msg): if n == len(msg):
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from time import time from time import time
from neo import logging import neo
from neo.epoll import Epoll from neo.epoll import Epoll
from neo.profiling import profiler_decorator from neo.profiling import profiler_decorator
...@@ -184,13 +184,14 @@ class EpollEventManager(object): ...@@ -184,13 +184,14 @@ class EpollEventManager(object):
self.epoll.modify(fd, fd in self.reader_set, 0) self.epoll.modify(fd, fd in self.reader_set, 0)
def log(self): def log(self):
logging.info('Event Manager:') neo.logging.info('Event Manager:')
logging.info(' Readers: %r', [x for x in self.reader_set]) neo.logging.info(' Readers: %r', [x for x in self.reader_set])
logging.info(' Writers: %r', [x for x in self.writer_set]) neo.logging.info(' Writers: %r', [x for x in self.writer_set])
logging.info(' Connections:') neo.logging.info(' Connections:')
pending_set = set(self._pending_processing) pending_set = set(self._pending_processing)
for fd, conn in self.connection_dict.items(): for fd, conn in self.connection_dict.items():
logging.info(' %r: %r (pending=%r)', fd, conn, conn in pending_set) neo.logging.info(' %r: %r (pending=%r)', fd, conn,
conn in pending_set)
# Default to EpollEventManager. # Default to EpollEventManager.
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.protocol import NodeStates, ErrorCodes, Packets, Errors from neo.protocol import NodeStates, ErrorCodes, Packets, Errors
from neo.protocol import PacketMalformedError, UnexpectedPacketError, \ from neo.protocol import PacketMalformedError, UnexpectedPacketError, \
BrokenNodeDisallowedError, NotReadyError, ProtocolError BrokenNodeDisallowedError, NotReadyError, ProtocolError
...@@ -40,7 +40,7 @@ class EventHandler(object): ...@@ -40,7 +40,7 @@ class EventHandler(object):
else: else:
message = 'unexpected packet: %s in %s' % (message, message = 'unexpected packet: %s in %s' % (message,
self.__class__.__name__) self.__class__.__name__)
logging.error(message) neo.logging.error(message)
conn.answer(Errors.ProtocolError(message)) conn.answer(Errors.ProtocolError(message))
conn.abort() conn.abort()
self.peerBroken(conn) self.peerBroken(conn)
...@@ -58,7 +58,7 @@ class EventHandler(object): ...@@ -58,7 +58,7 @@ class EventHandler(object):
except UnexpectedPacketError, e: except UnexpectedPacketError, e:
self.__unexpectedPacket(conn, packet, *e.args) self.__unexpectedPacket(conn, packet, *e.args)
except PacketMalformedError: except PacketMalformedError:
logging.error('malformed packet from %r', conn) neo.logging.error('malformed packet from %r', conn)
conn.notify(Packets.Notify('Malformed packet: %r' % (packet, ))) conn.notify(Packets.Notify('Malformed packet: %r' % (packet, )))
conn.abort() conn.abort()
self.peerBroken(conn) self.peerBroken(conn)
...@@ -82,7 +82,7 @@ class EventHandler(object): ...@@ -82,7 +82,7 @@ class EventHandler(object):
def checkClusterName(self, name): def checkClusterName(self, name):
# raise an exception if the fiven name mismatch the current cluster name # raise an exception if the fiven name mismatch the current cluster name
if self.app.name != name: if self.app.name != name:
logging.error('reject an alien cluster') neo.logging.error('reject an alien cluster')
raise ProtocolError('invalid cluster name') raise ProtocolError('invalid cluster name')
...@@ -94,32 +94,32 @@ class EventHandler(object): ...@@ -94,32 +94,32 @@ class EventHandler(object):
def connectionStarted(self, conn): def connectionStarted(self, conn):
"""Called when a connection is started.""" """Called when a connection is started."""
logging.debug('connection started for %r', conn) neo.logging.debug('connection started for %r', conn)
def connectionCompleted(self, conn): def connectionCompleted(self, conn):
"""Called when a connection is completed.""" """Called when a connection is completed."""
logging.debug('connection completed for %r', conn) neo.logging.debug('connection completed for %r', conn)
def connectionFailed(self, conn): def connectionFailed(self, conn):
"""Called when a connection failed.""" """Called when a connection failed."""
logging.debug('connection failed for %r', conn) neo.logging.debug('connection failed for %r', conn)
def connectionAccepted(self, conn): def connectionAccepted(self, conn):
"""Called when a connection is accepted.""" """Called when a connection is accepted."""
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
"""Called when a timeout event occurs.""" """Called when a timeout event occurs."""
logging.debug('timeout expired for %r', conn) neo.logging.debug('timeout expired for %r', conn)
self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN) self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN)
def connectionClosed(self, conn): def connectionClosed(self, conn):
"""Called when a connection is closed by the peer.""" """Called when a connection is closed by the peer."""
logging.debug('connection closed for %r', conn) neo.logging.debug('connection closed for %r', conn)
self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN) self.connectionLost(conn, NodeStates.TEMPORARILY_DOWN)
def peerBroken(self, conn): def peerBroken(self, conn):
"""Called when a peer is broken.""" """Called when a peer is broken."""
logging.error('%r is broken', conn) neo.logging.error('%r is broken', conn)
self.connectionLost(conn, NodeStates.BROKEN) self.connectionLost(conn, NodeStates.BROKEN)
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
...@@ -131,7 +131,7 @@ class EventHandler(object): ...@@ -131,7 +131,7 @@ class EventHandler(object):
# Packet handlers. # Packet handlers.
def notify(self, conn, message): def notify(self, conn, message):
logging.info('notification from %r: %s', conn, message) neo.logging.info('notification from %r: %s', conn, message)
def requestIdentification(self, conn, node_type, def requestIdentification(self, conn, node_type,
uuid, address, name): uuid, address, name):
...@@ -395,16 +395,16 @@ class EventHandler(object): ...@@ -395,16 +395,16 @@ class EventHandler(object):
def protocolError(self, conn, message): def protocolError(self, conn, message):
# the connection should have been closed by the remote peer # the connection should have been closed by the remote peer
logging.error('protocol error: %s' % (message,)) neo.logging.error('protocol error: %s' % (message,))
def timeoutError(self, conn, message): def timeoutError(self, conn, message):
logging.error('timeout error: %s' % (message,)) neo.logging.error('timeout error: %s' % (message,))
def brokenNodeDisallowedError(self, conn, message): def brokenNodeDisallowedError(self, conn, message):
raise RuntimeError, 'broken node disallowed error: %s' % (message,) raise RuntimeError, 'broken node disallowed error: %s' % (message,)
def ack(self, conn, message): def ack(self, conn, message):
logging.debug("no error message : %s" % (message)) neo.logging.debug("no error message : %s" % (message))
# Fetch tables initialization # Fetch tables initialization
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.protocol import PacketMalformedError from neo.protocol import PacketMalformedError
from neo.util import dump from neo.util import dump
from neo.handler import EventHandler from neo.handler import EventHandler
from neo.profiling import profiler_decorator from neo.profiling import profiler_decorator
LOGGER_ENABLED = False LOGGER_ENABLED = True
class PacketLogger(object): class PacketLogger(object):
""" Logger at packet level (for debugging purpose) """ """ Logger at packet level (for debugging purpose) """
...@@ -37,7 +37,7 @@ class PacketLogger(object): ...@@ -37,7 +37,7 @@ class PacketLogger(object):
klass = packet.getType() klass = packet.getType()
uuid = dump(conn.getUUID()) uuid = dump(conn.getUUID())
ip, port = conn.getAddress() ip, port = conn.getAddress()
logging.debug('#0x%08x %-30s %s %s (%s:%d)', packet.getId(), neo.logging.debug('#0x%08x %-30s %s %s (%s:%d)', packet.getId(),
packet.__class__.__name__, direction, uuid, ip, port) packet.__class__.__name__, direction, uuid, ip, port)
# look for custom packet logger # look for custom packet logger
logger = self.packet_dispatch_table.get(klass, None) logger = self.packet_dispatch_table.get(klass, None)
...@@ -48,11 +48,11 @@ class PacketLogger(object): ...@@ -48,11 +48,11 @@ class PacketLogger(object):
try: try:
args = packet.decode() or () args = packet.decode() or ()
except PacketMalformedError: except PacketMalformedError:
logging.warning("Can't decode packet for logging") neo.logging.warning("Can't decode packet for logging")
return return
log_message = logger(conn, *args) log_message = logger(conn, *args)
if log_message is not None: if log_message is not None:
logging.debug('#0x%08x %s', packet.getId(), log_message) neo.logging.debug('#0x%08x %s', packet.getId(), log_message)
def error(self, conn, code, message): def error(self, conn, code, message):
return "%s (%s)" % (code, message) return "%s (%s)" % (code, message)
...@@ -64,7 +64,7 @@ class PacketLogger(object): ...@@ -64,7 +64,7 @@ class PacketLogger(object):
else: else:
address = '?' address = '?'
node = (dump(uuid), node_type, address, state) node = (dump(uuid), node_type, address, state)
logging.debug(' ! %s | %8s | %22s | %s' % node) neo.logging.debug(' ! %s | %8s | %22s | %s' % node)
PACKET_LOGGER = PacketLogger() PACKET_LOGGER = PacketLogger()
if not LOGGER_ENABLED: if not LOGGER_ENABLED:
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
import os, sys import os, sys
from time import time from time import time
...@@ -60,7 +60,7 @@ class Application(object): ...@@ -60,7 +60,7 @@ class Application(object):
for address in config.getMasters(): for address in config.getMasters():
self.nm.createMaster(address=address) self.nm.createMaster(address=address)
logging.debug('IP address is %s, port is %d', *(self.server)) neo.logging.debug('IP address is %s, port is %d', *(self.server))
# Partition table # Partition table
replicas, partitions = config.getReplicas(), config.getPartitions() replicas, partitions = config.getReplicas(), config.getPartitions()
...@@ -69,10 +69,10 @@ class Application(object): ...@@ -69,10 +69,10 @@ class Application(object):
if partitions <= 0: if partitions <= 0:
raise RuntimeError, 'partitions must be more than zero' raise RuntimeError, 'partitions must be more than zero'
self.pt = PartitionTable(partitions, replicas) self.pt = PartitionTable(partitions, replicas)
logging.info('Configuration:') neo.logging.info('Configuration:')
logging.info('Partitions: %d', partitions) neo.logging.info('Partitions: %d', partitions)
logging.info('Replicas : %d', replicas) neo.logging.info('Replicas : %d', replicas)
logging.info('Name : %s', self.name) neo.logging.info('Name : %s', self.name)
self.listening_conn = None self.listening_conn = None
self.primary = None self.primary = None
...@@ -105,7 +105,7 @@ class Application(object): ...@@ -105,7 +105,7 @@ class Application(object):
try: try:
self._run() self._run()
except: except:
logging.info('\nPre-mortem informations:') neo.logging.info('\nPre-mortem informations:')
self.log() self.log()
raise raise
...@@ -143,7 +143,7 @@ class Application(object): ...@@ -143,7 +143,7 @@ class Application(object):
others while attempting to connect to other master nodes at the others while attempting to connect to other master nodes at the
same time. Note that storage nodes and client nodes may connect same time. Note that storage nodes and client nodes may connect
to self as well as master nodes.""" to self as well as master nodes."""
logging.info('begin the election of a primary master') neo.logging.info('begin the election of a primary master')
self.unconnected_master_node_set.clear() self.unconnected_master_node_set.clear()
self.negotiating_master_node_set.clear() self.negotiating_master_node_set.clear()
...@@ -197,7 +197,7 @@ class Application(object): ...@@ -197,7 +197,7 @@ class Application(object):
for node in self.nm.getMasterList(): for node in self.nm.getMasterList():
if not node.isRunning() and node.getLastStateChange() + \ if not node.isRunning() and node.getLastStateChange() + \
expiration < current_time: expiration < current_time:
logging.info('%s is down' % (node, )) neo.logging.info('%s is down' % (node, ))
node.setDown() node.setDown()
self.unconnected_master_node_set.discard( self.unconnected_master_node_set.discard(
node.getAddress()) node.getAddress())
...@@ -220,7 +220,7 @@ class Application(object): ...@@ -220,7 +220,7 @@ class Application(object):
Broadcast the announce that I'm the primary Broadcast the announce that I'm the primary
""" """
# I am the primary. # I am the primary.
logging.debug('I am the primary, sending an announcement') neo.logging.debug('I am the primary, sending an announcement')
for conn in self.em.getClientList(): for conn in self.em.getClientList():
conn.notify(Packets.AnnouncePrimary()) conn.notify(Packets.AnnouncePrimary())
conn.abort() conn.abort()
...@@ -237,7 +237,7 @@ class Application(object): ...@@ -237,7 +237,7 @@ class Application(object):
""" """
Ask other masters to reelect a primary after an election failure. Ask other masters to reelect a primary after an election failure.
""" """
logging.error('election failed: %s', (m, )) neo.logging.error('election failed: %s', (m, ))
# Ask all connected nodes to reelect a single primary master. # Ask all connected nodes to reelect a single primary master.
for conn in self.em.getClientList(): for conn in self.em.getClientList():
...@@ -286,7 +286,7 @@ class Application(object): ...@@ -286,7 +286,7 @@ class Application(object):
def broadcastPartitionChanges(self, cell_list): def broadcastPartitionChanges(self, cell_list):
"""Broadcast a Notify Partition Changes packet.""" """Broadcast a Notify Partition Changes packet."""
logging.debug('broadcastPartitionChanges') neo.logging.debug('broadcastPartitionChanges')
if not cell_list: if not cell_list:
return return
self.pt.log() self.pt.log()
...@@ -304,7 +304,7 @@ class Application(object): ...@@ -304,7 +304,7 @@ class Application(object):
def broadcastLastOID(self): def broadcastLastOID(self):
oid = self.tm.getLastOID() oid = self.tm.getLastOID()
logging.debug('Broadcast last OID to storages : %s' % dump(oid)) neo.logging.debug('Broadcast last OID to storages : %s' % dump(oid))
packet = Packets.NotifyLastOID(oid) packet = Packets.NotifyLastOID(oid)
for node in self.nm.getStorageList(only_identified=True): for node in self.nm.getStorageList(only_identified=True):
node.notify(packet) node.notify(packet)
...@@ -315,7 +315,7 @@ class Application(object): ...@@ -315,7 +315,7 @@ class Application(object):
and stop the service only if a catastrophy happens or the user commits and stop the service only if a catastrophy happens or the user commits
a shutdown. a shutdown.
""" """
logging.info('provide service') neo.logging.info('provide service')
em = self.em em = self.em
self.tm.reset() self.tm.reset()
...@@ -328,7 +328,7 @@ class Application(object): ...@@ -328,7 +328,7 @@ class Application(object):
except OperationFailure: except OperationFailure:
# If not operational, send Stop Operation packets to storage # If not operational, send Stop Operation packets to storage
# nodes and client nodes. Abort connections to client nodes. # nodes and client nodes. Abort connections to client nodes.
logging.critical('No longer operational, stopping the service') neo.logging.critical('No longer operational')
for node in self.nm.getIdentifiedList(): for node in self.nm.getIdentifiedList():
if node.isStorage() or node.isClient(): if node.isStorage() or node.isClient():
node.notify(Packets.StopOperation()) node.notify(Packets.StopOperation())
...@@ -341,7 +341,7 @@ class Application(object): ...@@ -341,7 +341,7 @@ class Application(object):
return return
def playPrimaryRole(self): def playPrimaryRole(self):
logging.info('play the primary role with %r', self.listening_conn) neo.logging.info('play the primary role with %r', self.listening_conn)
# i'm the primary, send the announcement # i'm the primary, send the announcement
self._announcePrimary() self._announcePrimary()
...@@ -378,7 +378,8 @@ class Application(object): ...@@ -378,7 +378,8 @@ class Application(object):
""" """
I play a secondary role, thus only wait for a primary master to fail. I play a secondary role, thus only wait for a primary master to fail.
""" """
logging.info('play the secondary role with %r', self.listening_conn) neo.logging.info('play the secondary role with %r',
self.listening_conn)
# Wait for an announcement. If this is too long, probably # Wait for an announcement. If this is too long, probably
# the primary master is down. # the primary master is down.
...@@ -491,7 +492,7 @@ class Application(object): ...@@ -491,7 +492,7 @@ class Application(object):
self.em.poll(1) self.em.poll(1)
if self.cluster_state != ClusterStates.RUNNING: if self.cluster_state != ClusterStates.RUNNING:
logging.info("asking all nodes to shutdown") neo.logging.info("asking all nodes to shutdown")
# This code sends packets but never polls, so they never reach # This code sends packets but never polls, so they never reach
# network. # network.
for node in self.nm.getIdentifiedList(): for node in self.nm.getIdentifiedList():
...@@ -528,7 +529,7 @@ class Application(object): ...@@ -528,7 +529,7 @@ class Application(object):
# always accept admin nodes # always accept admin nodes
node_ctor = self.nm.createAdmin node_ctor = self.nm.createAdmin
handler = administration.AdministrationHandler(self) handler = administration.AdministrationHandler(self)
logging.info('Accept an admin %s' % (dump(uuid), )) neo.logging.info('Accept an admin %s' % (dump(uuid), ))
elif node_type == NodeTypes.MASTER: elif node_type == NodeTypes.MASTER:
if node is None: if node is None:
# unknown master, rejected # unknown master, rejected
...@@ -536,15 +537,15 @@ class Application(object): ...@@ -536,15 +537,15 @@ class Application(object):
# always put other master in waiting state # always put other master in waiting state
node_ctor = self.nm.createMaster node_ctor = self.nm.createMaster
handler = secondary.SecondaryMasterHandler(self) handler = secondary.SecondaryMasterHandler(self)
logging.info('Accept a master %s' % (dump(uuid), )) neo.logging.info('Accept a master %s' % (dump(uuid), ))
elif node_type == NodeTypes.CLIENT: elif node_type == NodeTypes.CLIENT:
# refuse any client before running # refuse any client before running
if self.cluster_state != ClusterStates.RUNNING: if self.cluster_state != ClusterStates.RUNNING:
logging.info('Reject a connection from a client') neo.logging.info('Reject a connection from a client')
raise protocol.NotReadyError raise protocol.NotReadyError
node_ctor = self.nm.createClient node_ctor = self.nm.createClient
handler = client.ClientServiceHandler(self) handler = client.ClientServiceHandler(self)
logging.info('Accept a client %s' % (dump(uuid), )) neo.logging.info('Accept a client %s' % (dump(uuid), ))
elif node_type == NodeTypes.STORAGE: elif node_type == NodeTypes.STORAGE:
node_ctor = self.nm.createStorage node_ctor = self.nm.createStorage
if self._current_manager is not None: if self._current_manager is not None:
...@@ -552,7 +553,7 @@ class Application(object): ...@@ -552,7 +553,7 @@ class Application(object):
(uuid, state, handler) = identify(uuid, node) (uuid, state, handler) = identify(uuid, node)
else: else:
(uuid, state, handler) = self.identifyStorageNode(uuid, node) (uuid, state, handler) = self.identifyStorageNode(uuid, node)
logging.info('Accept a storage %s (%s)' % (dump(uuid), state)) neo.logging.info('Accept a storage %s (%s)' % (dump(uuid), state))
return (uuid, node, state, handler, node_ctor) return (uuid, node, state, handler, node_ctor)
def setStorageNotReady(self, uuid): def setStorageNotReady(self, uuid):
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.handler import EventHandler from neo.handler import EventHandler
from neo.protocol import NodeTypes, NodeStates, Packets from neo.protocol import NodeTypes, NodeStates, Packets
...@@ -25,7 +25,7 @@ class MasterHandler(EventHandler): ...@@ -25,7 +25,7 @@ class MasterHandler(EventHandler):
"""This class implements a generic part of the event handlers.""" """This class implements a generic part of the event handlers."""
def protocolError(self, conn, message): def protocolError(self, conn, message):
logging.error('Protocol error %s %s' % (message, conn.getAddress())) neo.logging.error('Protocol error %s %s', message, conn.getAddress())
def askPrimary(self, conn): def askPrimary(self, conn):
if conn.getConnector() is None: if conn.getConnector() is None:
...@@ -101,7 +101,7 @@ class BaseServiceHandler(MasterHandler): ...@@ -101,7 +101,7 @@ class BaseServiceHandler(MasterHandler):
if new_state != NodeStates.BROKEN and was_pending: if new_state != NodeStates.BROKEN and was_pending:
# was in pending state, so drop it from the node manager to forget # was in pending state, so drop it from the node manager to forget
# it and do not set in running state when it comes back # it and do not set in running state when it comes back
logging.info('drop a pending node from the node manager') neo.logging.info('drop a pending node from the node manager')
self.app.nm.remove(node) self.app.nm.remove(node)
self.app.broadcastNodesInformation([node]) self.app.broadcastNodesInformation([node])
# clean node related data in specialized handlers # clean node related data in specialized handlers
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.master.handlers import MasterHandler from neo.master.handlers import MasterHandler
from neo.protocol import ClusterStates, NodeStates, Packets, ProtocolError from neo.protocol import ClusterStates, NodeStates, Packets, ProtocolError
...@@ -63,7 +63,7 @@ class AdministrationHandler(MasterHandler): ...@@ -63,7 +63,7 @@ class AdministrationHandler(MasterHandler):
self.app.shutdown() self.app.shutdown()
def setNodeState(self, conn, uuid, state, modify_partition_table): def setNodeState(self, conn, uuid, state, modify_partition_table):
logging.info("set node state for %s-%s : %s" % neo.logging.info("set node state for %s-%s : %s" %
(dump(uuid), state, modify_partition_table)) (dump(uuid), state, modify_partition_table))
app = self.app app = self.app
node = app.nm.getByUUID(uuid) node = app.nm.getByUUID(uuid)
...@@ -119,7 +119,7 @@ class AdministrationHandler(MasterHandler): ...@@ -119,7 +119,7 @@ class AdministrationHandler(MasterHandler):
def addPendingNodes(self, conn, uuid_list): def addPendingNodes(self, conn, uuid_list):
uuids = ', '.join([dump(uuid) for uuid in uuid_list]) uuids = ', '.join([dump(uuid) for uuid in uuid_list])
logging.debug('Add nodes %s' % uuids) neo.logging.debug('Add nodes %s' % uuids)
app, nm, em, pt = self.app, self.app.nm, self.app.em, self.app.pt app, nm, em, pt = self.app, self.app.nm, self.app.em, self.app.pt
cell_list = [] cell_list = []
uuid_set = set() uuid_set = set()
...@@ -132,11 +132,11 @@ class AdministrationHandler(MasterHandler): ...@@ -132,11 +132,11 @@ class AdministrationHandler(MasterHandler):
uuid_set = uuid_set.intersection(set(uuid_list)) uuid_set = uuid_set.intersection(set(uuid_list))
# nothing to do # nothing to do
if not uuid_set: if not uuid_set:
logging.warning('No nodes added') neo.logging.warning('No nodes added')
conn.answer(Errors.Ack('No nodes added')) conn.answer(Errors.Ack('No nodes added'))
return return
uuids = ', '.join([dump(uuid) for uuid in uuid_set]) uuids = ', '.join([dump(uuid) for uuid in uuid_set])
logging.info('Adding nodes %s' % uuids) neo.logging.info('Adding nodes %s' % uuids)
# switch nodes to running state # switch nodes to running state
node_list = [nm.getByUUID(uuid) for uuid in uuid_set] node_list = [nm.getByUUID(uuid) for uuid in uuid_set]
for node in node_list: for node in node_list:
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.protocol import NodeStates, Packets, ProtocolError from neo.protocol import NodeStates, Packets, ProtocolError
from neo.master.handlers import MasterHandler from neo.master.handlers import MasterHandler
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.protocol import NodeTypes, Packets from neo.protocol import NodeTypes, Packets
from neo.protocol import NotReadyError, ProtocolError, UnexpectedPacketError from neo.protocol import NotReadyError, ProtocolError, UnexpectedPacketError
...@@ -90,7 +90,7 @@ class ClientElectionHandler(MasterHandler): ...@@ -90,7 +90,7 @@ class ClientElectionHandler(MasterHandler):
node = app.nm.getByAddress(conn.getAddress()) node = app.nm.getByAddress(conn.getAddress())
if node_type != NodeTypes.MASTER: if node_type != NodeTypes.MASTER:
# The peer is not a master node! # The peer is not a master node!
logging.error('%r is not a master node', conn) neo.logging.error('%r is not a master node', conn)
app.nm.remove(node) app.nm.remove(node)
app.negotiating_master_node_set.discard(node.getAddress()) app.negotiating_master_node_set.discard(node.getAddress())
conn.close() conn.close()
...@@ -137,7 +137,7 @@ class ClientElectionHandler(MasterHandler): ...@@ -137,7 +137,7 @@ class ClientElectionHandler(MasterHandler):
if primary_node is None: if primary_node is None:
# I don't know such a node. Probably this information # I don't know such a node. Probably this information
# is old. So ignore it. # is old. So ignore it.
logging.warning('received an unknown primary node UUID') neo.logging.warning('received an unknown primary node UUID')
else: else:
# Whatever the situation is, I trust this master. # Whatever the situation is, I trust this master.
app.primary = False app.primary = False
...@@ -203,11 +203,11 @@ class ServerElectionHandler(MasterHandler): ...@@ -203,11 +203,11 @@ class ServerElectionHandler(MasterHandler):
self.checkClusterName(name) self.checkClusterName(name)
app = self.app app = self.app
if node_type != NodeTypes.MASTER: if node_type != NodeTypes.MASTER:
logging.info('reject a connection from a non-master') neo.logging.info('reject a connection from a non-master')
raise NotReadyError raise NotReadyError
node = app.nm.getByAddress(address) node = app.nm.getByAddress(address)
if node is None: if node is None:
logging.error('unknown master node: %s' % (address, )) neo.logging.error('unknown master node: %s' % (address, ))
raise ProtocolError('unknown master node') raise ProtocolError('unknown master node')
# If this node is broken, reject it. # If this node is broken, reject it.
if node.getUUID() == uuid: if node.getUUID() == uuid:
...@@ -243,5 +243,5 @@ class ServerElectionHandler(MasterHandler): ...@@ -243,5 +243,5 @@ class ServerElectionHandler(MasterHandler):
app.primary_master_node = node app.primary_master_node = node
app.unconnected_master_node_set.clear() app.unconnected_master_node_set.clear()
app.negotiating_master_node_set.clear() app.negotiating_master_node_set.clear()
logging.info('%s is the primary', node) neo.logging.info('%s is the primary', node)
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.protocol import NodeTypes, Packets from neo.protocol import NodeTypes, Packets
from neo.protocol import BrokenNodeDisallowedError, ProtocolError from neo.protocol import BrokenNodeDisallowedError, ProtocolError
...@@ -25,7 +25,7 @@ class IdentificationHandler(MasterHandler): ...@@ -25,7 +25,7 @@ class IdentificationHandler(MasterHandler):
"""This class deals with messages from the admin node only""" """This class deals with messages from the admin node only"""
def nodeLost(self, conn, node): def nodeLost(self, conn, node):
logging.warning('lost a node in IdentificationHandler : %s' % node) neo.logging.warning('lost a node in IdentificationHandler : %s' % node)
def requestIdentification(self, conn, node_type, uuid, address, name): def requestIdentification(self, conn, node_type, uuid, address, name):
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo import protocol from neo import protocol
from neo.master.handlers import BaseServiceHandler from neo.master.handlers import BaseServiceHandler
...@@ -24,15 +24,15 @@ class ShutdownHandler(BaseServiceHandler): ...@@ -24,15 +24,15 @@ class ShutdownHandler(BaseServiceHandler):
def requestIdentification(self, conn, node_type, def requestIdentification(self, conn, node_type,
uuid, address, name): uuid, address, name):
logging.error('reject any new connection') neo.logging.error('reject any new connection')
raise protocol.ProtocolError('cluster is shutting down') raise protocol.ProtocolError('cluster is shutting down')
def askPrimary(self, conn): def askPrimary(self, conn):
logging.error('reject any new demand for primary master') neo.logging.error('reject any new demand for primary master')
raise protocol.ProtocolError('cluster is shutting down') raise protocol.ProtocolError('cluster is shutting down')
def askBeginTransaction(self, conn, tid): def askBeginTransaction(self, conn, tid):
logging.error('reject any new demand for new tid') neo.logging.error('reject any new demand for new tid')
raise protocol.ProtocolError('cluster is shutting down') raise protocol.ProtocolError('cluster is shutting down')
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.protocol import ProtocolError from neo.protocol import ProtocolError
from neo.protocol import CellStates, Packets from neo.protocol import CellStates, Packets
...@@ -39,7 +39,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -39,7 +39,7 @@ class StorageServiceHandler(BaseServiceHandler):
conn.notify(Packets.StartOperation()) conn.notify(Packets.StartOperation())
def nodeLost(self, conn, node): def nodeLost(self, conn, node):
logging.info('storage node lost') neo.logging.info('storage node lost')
assert not node.isRunning(), node.getState() assert not node.isRunning(), node.getState()
if not self.app.pt.operational(): if not self.app.pt.operational():
...@@ -109,7 +109,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -109,7 +109,7 @@ class StorageServiceHandler(BaseServiceHandler):
def notifyReplicationDone(self, conn, offset): def notifyReplicationDone(self, conn, offset):
uuid = conn.getUUID() uuid = conn.getUUID()
node = self.app.nm.getByUUID(uuid) node = self.app.nm.getByUUID(uuid)
logging.debug("node %s is up for offset %s" % (dump(uuid), offset)) neo.logging.debug("node %s is up for offset %s" % (dump(uuid), offset))
# check the partition is assigned and known as outdated # check the partition is assigned and known as outdated
for cell in self.app.pt.getCellList(offset): for cell in self.app.pt.getCellList(offset):
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from struct import pack from struct import pack
from neo import logging import neo
from neo.util import dump from neo.util import dump
from neo.protocol import Packets, ProtocolError, ClusterStates, NodeStates from neo.protocol import Packets, ProtocolError, ClusterStates, NodeStates
from neo.protocol import NotReadyError, ZERO_OID, ZERO_TID from neo.protocol import NotReadyError, ZERO_OID, ZERO_TID
...@@ -43,7 +43,7 @@ class RecoveryManager(MasterHandler): ...@@ -43,7 +43,7 @@ class RecoveryManager(MasterHandler):
Returns the handler for storage nodes Returns the handler for storage nodes
""" """
if uuid is None and not self.app._startup_allowed: if uuid is None and not self.app._startup_allowed:
logging.info('reject empty storage node') neo.logging.info('reject empty storage node')
raise NotReadyError raise NotReadyError
return (uuid, NodeStates.RUNNING, self) return (uuid, NodeStates.RUNNING, self)
...@@ -54,7 +54,7 @@ class RecoveryManager(MasterHandler): ...@@ -54,7 +54,7 @@ class RecoveryManager(MasterHandler):
back the latest partition table or make a new table from scratch, back the latest partition table or make a new table from scratch,
if this is the first time. if this is the first time.
""" """
logging.info('begin the recovery of the status') neo.logging.info('begin the recovery of the status')
self.app.changeClusterState(ClusterStates.RECOVERING) self.app.changeClusterState(ClusterStates.RECOVERING)
em = self.app.em em = self.app.em
...@@ -66,7 +66,7 @@ class RecoveryManager(MasterHandler): ...@@ -66,7 +66,7 @@ class RecoveryManager(MasterHandler):
while not self.app._startup_allowed: while not self.app._startup_allowed:
em.poll(1) em.poll(1)
logging.info('startup allowed') neo.logging.info('startup allowed')
# build a new partition table # build a new partition table
if self.app.pt.getID() is None: if self.app.pt.getID() is None:
...@@ -80,13 +80,14 @@ class RecoveryManager(MasterHandler): ...@@ -80,13 +80,14 @@ class RecoveryManager(MasterHandler):
node.setPending() node.setPending()
self.app.broadcastNodesInformation(refused_node_set) self.app.broadcastNodesInformation(refused_node_set)
logging.debug('cluster starts with loid=%s and this partition table :', neo.logging.debug('cluster starts with loid=%s and this partition ' \
dump(self.app.tm.getLastOID())) 'table :', dump(self.app.tm.getLastOID()))
self.app.pt.log() self.app.pt.log()
def buildFromScratch(self): def buildFromScratch(self):
nm, em, pt = self.app.nm, self.app.em, self.app.pt nm, em, pt = self.app.nm, self.app.em, self.app.pt
logging.debug('creating a new partition table, wait for a storage node') neo.logging.debug('creating a new partition table, wait for a ' \
'storage node')
# wait for some empty storage nodes, their are accepted # wait for some empty storage nodes, their are accepted
while len(nm.getStorageList()) < REQUIRED_NODE_NUMBER: while len(nm.getStorageList()) < REQUIRED_NODE_NUMBER:
em.poll(1) em.poll(1)
...@@ -127,7 +128,7 @@ class RecoveryManager(MasterHandler): ...@@ -127,7 +128,7 @@ class RecoveryManager(MasterHandler):
def answerPartitionTable(self, conn, ptid, row_list): def answerPartitionTable(self, conn, ptid, row_list):
if ptid != self.target_ptid: if ptid != self.target_ptid:
# If this is not from a target node, ignore it. # If this is not from a target node, ignore it.
logging.warn('Got %s while waiting %s', dump(ptid), neo.logging.warn('Got %s while waiting %s', dump(ptid),
dump(self.target_ptid)) dump(self.target_ptid))
return return
try: try:
......
...@@ -19,7 +19,7 @@ from time import time, gmtime ...@@ -19,7 +19,7 @@ from time import time, gmtime
from struct import pack, unpack from struct import pack, unpack
from datetime import timedelta, datetime from datetime import timedelta, datetime
from neo.util import dump from neo.util import dump
from neo import logging import neo
class Transaction(object): class Transaction(object):
""" """
...@@ -269,7 +269,7 @@ class TransactionManager(object): ...@@ -269,7 +269,7 @@ class TransactionManager(object):
del self._node_dict[node] del self._node_dict[node]
def log(self): def log(self):
logging.info('Transactions:') neo.logging.info('Transactions:')
for txn in self._tid_dict.itervalues(): for txn in self._tid_dict.itervalues():
logging.info(' %r', txn) neo.logging.info(' %r', txn)
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.util import dump from neo.util import dump
from neo.protocol import ClusterStates, Packets, NodeStates from neo.protocol import ClusterStates, Packets, NodeStates
from neo.master.handlers import BaseServiceHandler from neo.master.handlers import BaseServiceHandler
...@@ -117,11 +117,11 @@ class VerificationManager(BaseServiceHandler): ...@@ -117,11 +117,11 @@ class VerificationManager(BaseServiceHandler):
em, nm = self.app.em, self.app.nm em, nm = self.app.em, self.app.nm
# wait for any missing node # wait for any missing node
logging.debug('waiting for the cluster to be operational') neo.logging.debug('waiting for the cluster to be operational')
while not self.app.pt.operational(): while not self.app.pt.operational():
em.poll(1) em.poll(1)
logging.info('start to verify data') neo.logging.info('start to verify data')
# Gather all unfinished transactions. # Gather all unfinished transactions.
self._askStorageNodesAndWait(Packets.AskUnfinishedTransactions(), self._askStorageNodesAndWait(Packets.AskUnfinishedTransactions(),
...@@ -196,7 +196,7 @@ class VerificationManager(BaseServiceHandler): ...@@ -196,7 +196,7 @@ class VerificationManager(BaseServiceHandler):
def answerUnfinishedTransactions(self, conn, tid_list): def answerUnfinishedTransactions(self, conn, tid_list):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('got unfinished transactions %s from %r', neo.logging.info('got unfinished transactions %s from %r',
[dump(tid) for tid in tid_list], conn) [dump(tid) for tid in tid_list], conn)
if not self._gotAnswerFrom(uuid): if not self._gotAnswerFrom(uuid):
return return
...@@ -221,19 +221,19 @@ class VerificationManager(BaseServiceHandler): ...@@ -221,19 +221,19 @@ class VerificationManager(BaseServiceHandler):
def tidNotFound(self, conn, message): def tidNotFound(self, conn, message):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('TID not found: %s', message) neo.logging.info('TID not found: %s', message)
if not self._gotAnswerFrom(uuid): if not self._gotAnswerFrom(uuid):
return return
self._oid_set = None self._oid_set = None
def answerObjectPresent(self, conn, oid, tid): def answerObjectPresent(self, conn, oid, tid):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('object %s:%s found', dump(oid), dump(tid)) neo.logging.info('object %s:%s found', dump(oid), dump(tid))
self._gotAnswerFrom(uuid) self._gotAnswerFrom(uuid)
def oidNotFound(self, conn, message): def oidNotFound(self, conn, message):
uuid = conn.getUUID() uuid = conn.getUUID()
logging.info('OID not found: %s', message) neo.logging.info('OID not found: %s', message)
app = self.app app = self.app
if not self._gotAnswerFrom(uuid): if not self._gotAnswerFrom(uuid):
return return
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from time import time from time import time
from neo import logging import neo
from neo.util import dump from neo.util import dump
from neo.protocol import NodeTypes, NodeStates from neo.protocol import NodeTypes, NodeStates
...@@ -263,7 +263,7 @@ class NodeManager(object): ...@@ -263,7 +263,7 @@ class NodeManager(object):
def add(self, node): def add(self, node):
if node in self._node_set: if node in self._node_set:
logging.warning('adding a known node %r, ignoring', node) neo.logging.warning('adding a known node %r, ignoring', node)
return return
self._node_set.add(node) self._node_set.add(node)
self._updateAddress(node, None) self._updateAddress(node, None)
...@@ -274,7 +274,7 @@ class NodeManager(object): ...@@ -274,7 +274,7 @@ class NodeManager(object):
def remove(self, node): def remove(self, node):
if node not in self._node_set: if node not in self._node_set:
logging.warning('removing unknown node %r, ignoring', node) neo.logging.warning('removing unknown node %r, ignoring', node)
return return
self._node_set.remove(node) self._node_set.remove(node)
self.__drop(self._address_dict, node.getAddress()) self.__drop(self._address_dict, node.getAddress())
...@@ -446,11 +446,12 @@ class NodeManager(object): ...@@ -446,11 +446,12 @@ class NodeManager(object):
log_args = (node_type, dump(uuid), addr, state) log_args = (node_type, dump(uuid), addr, state)
if node is None: if node is None:
if state == NodeStates.DOWN: if state == NodeStates.DOWN:
logging.debug('NOT creating node %s %s %s %s', *log_args) neo.logging.debug('NOT creating node %s %s %s %s',
*log_args)
else: else:
node = self._createNode(klass, address=addr, uuid=uuid, node = self._createNode(klass, address=addr, uuid=uuid,
state=state) state=state)
logging.debug('creating node %r', node) neo.logging.debug('creating node %r', node)
else: else:
assert isinstance(node, klass), 'node %r is not ' \ assert isinstance(node, klass), 'node %r is not ' \
'of expected type: %r' % (node, klass) 'of expected type: %r' % (node, klass)
...@@ -459,14 +460,14 @@ class NodeManager(object): ...@@ -459,14 +460,14 @@ class NodeManager(object):
'Discrepancy between node_by_uuid (%r) and ' \ 'Discrepancy between node_by_uuid (%r) and ' \
'node_by_addr (%r)' % (node_by_uuid, node_by_addr) 'node_by_addr (%r)' % (node_by_uuid, node_by_addr)
if state == NodeStates.DOWN: if state == NodeStates.DOWN:
logging.debug('droping node %r (%r), found with %s %s %s %s', neo.logging.debug('droping node %r (%r), found with %s ' \
node, node.isConnected(), *log_args) '%s %s %s', node, node.isConnected(), *log_args)
if node.isConnected(): if node.isConnected():
# cut this connection, node removed by handler # cut this connection, node removed by handler
node.getConnection().close() node.getConnection().close()
self.remove(node) self.remove(node)
else: else:
logging.debug('updating node %r to %s %s %s %s', neo.logging.debug('updating node %r to %s %s %s %s',
node, *log_args) node, *log_args)
node.setUUID(uuid) node.setUUID(uuid)
node.setAddress(addr) node.setAddress(addr)
...@@ -474,12 +475,12 @@ class NodeManager(object): ...@@ -474,12 +475,12 @@ class NodeManager(object):
self.log() self.log()
def log(self): def log(self):
logging.info('Node manager : %d nodes' % len(self._node_set)) neo.logging.info('Node manager : %d nodes' % len(self._node_set))
for node in sorted(list(self._node_set)): for node in sorted(list(self._node_set)):
uuid = dump(node.getUUID()) or '-' * 32 uuid = dump(node.getUUID()) or '-' * 32
address = node.getAddress() or '' address = node.getAddress() or ''
if address: if address:
address = '%s:%d' % address address = '%s:%d' % address
logging.info(' * %32s | %8s | %22s | %s' % ( neo.logging.info(' * %32s | %8s | %22s | %s' % (
uuid, node.getType(), address, node.getState())) uuid, node.getType(), address, node.getState()))
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo import protocol from neo import protocol
from neo.protocol import CellStates from neo.protocol import CellStates
...@@ -205,7 +205,7 @@ class PartitionTable(object): ...@@ -205,7 +205,7 @@ class PartitionTable(object):
# the node must be known by the node manager # the node must be known by the node manager
assert node is not None assert node is not None
self.setCell(offset, node, state) self.setCell(offset, node, state)
logging.debug('partition table loaded') neo.logging.debug('partition table loaded')
self.log() self.log()
def update(self, ptid, cell_list, nm): def update(self, ptid, cell_list, nm):
...@@ -215,14 +215,14 @@ class PartitionTable(object): ...@@ -215,14 +215,14 @@ class PartitionTable(object):
is not known, it is created in the node manager and set as unavailable is not known, it is created in the node manager and set as unavailable
""" """
if ptid <= self._id: if ptid <= self._id:
logging.warning('ignoring older partition changes') neo.logging.warning('ignoring older partition changes')
return return
self._id = ptid self._id = ptid
for offset, uuid, state in cell_list: for offset, uuid, state in cell_list:
node = nm.getByUUID(uuid) node = nm.getByUUID(uuid)
assert node is not None, 'No node found for uuid %r' % (dump(uuid), ) assert node is not None, 'No node found for uuid %r' % (dump(uuid), )
self.setCell(offset, node, state) self.setCell(offset, node, state)
logging.debug('partition table updated') neo.logging.debug('partition table updated')
self.log() self.log()
def filled(self): def filled(self):
...@@ -230,7 +230,7 @@ class PartitionTable(object): ...@@ -230,7 +230,7 @@ class PartitionTable(object):
def log(self): def log(self):
for line in self._format(): for line in self._format():
logging.debug(line) neo.logging.debug(line)
def format(self): def format(self):
return '\n'.join(self._format()) return '\n'.join(self._format())
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
import sys import sys
from collections import deque from collections import deque
...@@ -58,7 +58,7 @@ class Application(object): ...@@ -58,7 +58,7 @@ class Application(object):
# set the bind address # set the bind address
self.server = config.getBind() self.server = config.getBind()
logging.debug('IP address is %s, port is %d', *(self.server)) neo.logging.debug('IP address is %s, port is %d', *(self.server))
# The partition table is initialized after getting the number of # The partition table is initialized after getting the number of
# partitions. # partitions.
...@@ -126,12 +126,12 @@ class Application(object): ...@@ -126,12 +126,12 @@ class Application(object):
# create a partition table # create a partition table
self.pt = PartitionTable(num_partitions, num_replicas) self.pt = PartitionTable(num_partitions, num_replicas)
logging.info('Configuration loaded:') neo.logging.info('Configuration loaded:')
logging.info('UUID : %s', dump(self.uuid)) neo.logging.info('UUID : %s', dump(self.uuid))
logging.info('PTID : %s', dump(ptid)) neo.logging.info('PTID : %s', dump(ptid))
logging.info('Name : %s', self.name) neo.logging.info('Name : %s', self.name)
logging.info('Partitions: %s', num_partitions) neo.logging.info('Partitions: %s', num_partitions)
logging.info('Replicas : %s', num_replicas) neo.logging.info('Replicas : %s', num_replicas)
def loadPartitionTable(self): def loadPartitionTable(self):
"""Load a partition table from the database.""" """Load a partition table from the database."""
...@@ -156,7 +156,7 @@ class Application(object): ...@@ -156,7 +156,7 @@ class Application(object):
try: try:
self._run() self._run()
except: except:
logging.info('\nPre-mortem informations:') neo.logging.info('\nPre-mortem informations:')
self.log() self.log()
raise raise
...@@ -196,9 +196,9 @@ class Application(object): ...@@ -196,9 +196,9 @@ class Application(object):
self.doOperation() self.doOperation()
raise RuntimeError, 'should not reach here' raise RuntimeError, 'should not reach here'
except OperationFailure, msg: except OperationFailure, msg:
logging.error('operation stopped: %s', msg) neo.logging.error('operation stopped: %s', msg)
except PrimaryFailure, msg: except PrimaryFailure, msg:
logging.error('primary master is down: %s', msg) neo.logging.error('primary master is down: %s', msg)
self.master_node = None self.master_node = None
def connectToPrimary(self): def connectToPrimary(self):
...@@ -223,7 +223,7 @@ class Application(object): ...@@ -223,7 +223,7 @@ class Application(object):
(node, conn, uuid, num_partitions, num_replicas) = data (node, conn, uuid, num_partitions, num_replicas) = data
self.master_node = node self.master_node = node
self.master_conn = conn self.master_conn = conn
logging.info('I am %s', dump(uuid)) neo.logging.info('I am %s', dump(uuid))
self.uuid = uuid self.uuid = uuid
self.dm.setUUID(uuid) self.dm.setUUID(uuid)
...@@ -245,7 +245,7 @@ class Application(object): ...@@ -245,7 +245,7 @@ class Application(object):
def verifyData(self): def verifyData(self):
"""Verify data under the control by a primary master node. """Verify data under the control by a primary master node.
Connections from client nodes may not be accepted at this stage.""" Connections from client nodes may not be accepted at this stage."""
logging.info('verifying data') neo.logging.info('verifying data')
handler = verification.VerificationHandler(self) handler = verification.VerificationHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
...@@ -256,7 +256,7 @@ class Application(object): ...@@ -256,7 +256,7 @@ class Application(object):
def initialize(self): def initialize(self):
""" Retreive partition table and node informations from the primary """ """ Retreive partition table and node informations from the primary """
logging.debug('initializing...') neo.logging.debug('initializing...')
handler = initialization.InitializationHandler(self) handler = initialization.InitializationHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
...@@ -276,7 +276,7 @@ class Application(object): ...@@ -276,7 +276,7 @@ class Application(object):
def doOperation(self): def doOperation(self):
"""Handle everything, including replications and transactions.""" """Handle everything, including replications and transactions."""
logging.info('doing operation') neo.logging.info('doing operation')
em = self.em em = self.em
...@@ -302,7 +302,7 @@ class Application(object): ...@@ -302,7 +302,7 @@ class Application(object):
def wait(self): def wait(self):
# change handler # change handler
logging.info("waiting in hidden state") neo.logging.info("waiting in hidden state")
handler = hidden.HiddenHandler(self) handler = hidden.HiddenHandler(self)
for conn in self.em.getConnectionList(): for conn in self.em.getConnectionList():
conn.setHandler(handler) conn.setHandler(handler)
...@@ -330,11 +330,11 @@ class Application(object): ...@@ -330,11 +330,11 @@ class Application(object):
def logQueuedEvents(self): def logQueuedEvents(self):
if self.event_queue is None: if self.event_queue is None:
return return
logging.info("Pending events:") neo.logging.info("Pending events:")
for event, _msg_id, _conn, args, _kwargs in self.event_queue: for event, _msg_id, _conn, args, _kwargs in self.event_queue:
oid, serial, _compression, _checksum, data, tid, time = args oid, serial, _compression, _checksum, data, tid, time = args
logging.info(' %r: %r:%r by %r -> %r (%r)', event.__name__, dump(oid), neo.logging.info(' %r: %r:%r by %r -> %r (%r)', event.__name__,
dump(serial), dump(tid), data, time) dump(oid), dump(serial), dump(tid), data, time)
def shutdown(self, erase=False): def shutdown(self, erase=False):
"""Close all connections and exit""" """Close all connections and exit"""
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import MySQLdb import MySQLdb
from MySQLdb import OperationalError from MySQLdb import OperationalError
from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST from MySQLdb.constants.CR import SERVER_GONE_ERROR, SERVER_LOST
from neo import logging import neo
from array import array from array import array
import string import string
...@@ -68,7 +68,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -68,7 +68,7 @@ class MySQLDatabaseManager(DatabaseManager):
kwd = {'db' : self.db, 'user' : self.user} kwd = {'db' : self.db, 'user' : self.user}
if self.passwd is not None: if self.passwd is not None:
kwd['passwd'] = self.passwd kwd['passwd'] = self.passwd
logging.info('connecting to MySQL on the database %s with user %s', neo.logging.info('connecting to MySQL on the database %s with user %s',
self.db, self.user) self.db, self.user)
self.conn = MySQLdb.connect(**kwd) self.conn = MySQLdb.connect(**kwd)
self.conn.autocommit(False) self.conn.autocommit(False)
...@@ -78,12 +78,12 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -78,12 +78,12 @@ class MySQLDatabaseManager(DatabaseManager):
def _commit(self): def _commit(self):
if LOG_QUERIES: if LOG_QUERIES:
logging.debug('committing...') neo.logging.debug('committing...')
self.conn.commit() self.conn.commit()
def _rollback(self): def _rollback(self):
if LOG_QUERIES: if LOG_QUERIES:
logging.debug('aborting...') neo.logging.debug('aborting...')
self.conn.rollback() self.conn.rollback()
def query(self, query): def query(self, query):
...@@ -97,7 +97,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -97,7 +97,7 @@ class MySQLDatabaseManager(DatabaseManager):
c = '\\x%02x' % ord(c) c = '\\x%02x' % ord(c)
printable_char_list.append(c) printable_char_list.append(c)
query_part = ''.join(printable_char_list) query_part = ''.join(printable_char_list)
logging.debug('querying %s...', query_part) neo.logging.debug('querying %s...', query_part)
conn.query(query) conn.query(query)
r = conn.store_result() r = conn.store_result()
...@@ -114,7 +114,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -114,7 +114,7 @@ class MySQLDatabaseManager(DatabaseManager):
except OperationalError, m: except OperationalError, m:
if m[0] in (SERVER_GONE_ERROR, SERVER_LOST): if m[0] in (SERVER_GONE_ERROR, SERVER_LOST):
logging.info('the MySQL server is gone; reconnecting') neo.logging.info('the MySQL server is gone; reconnecting')
self._connect() self._connect()
return self.query(query) return self.query(query)
raise DatabaseFailure('MySQL error %d: %s' % (m[0], m[1])) raise DatabaseFailure('MySQL error %d: %s' % (m[0], m[1]))
...@@ -303,7 +303,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -303,7 +303,7 @@ class MySQLDatabaseManager(DatabaseManager):
}) })
compression, checksum, value, next_value_serial = r[0] compression, checksum, value, next_value_serial = r[0]
if value is None: if value is None:
logging.info("Multiple levels of indirection when " \ neo.logging.info("Multiple levels of indirection when " \
"searching for object data for oid %d at tid %d. This " \ "searching for object data for oid %d at tid %d. This " \
"causes suboptimal performance." % (oid, value_serial)) "causes suboptimal performance." % (oid, value_serial))
value_serial, compression, checksum, value = self._getObjectData( value_serial, compression, checksum, value = self._getObjectData(
...@@ -574,7 +574,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -574,7 +574,7 @@ class MySQLDatabaseManager(DatabaseManager):
(self._getPartition(oid), oid, value_serial)) (self._getPartition(oid), oid, value_serial))
length, value_serial = r[0] length, value_serial = r[0]
if length is None: if length is None:
logging.info("Multiple levels of indirection when " \ neo.logging.info("Multiple levels of indirection when " \
"searching for object data for oid %d at tid %d. This " \ "searching for object data for oid %d at tid %d. This " \
"causes suboptimal performance." % (oid, value_serial)) "causes suboptimal performance." % (oid, value_serial))
length = self._getObjectLength(oid, value_serial) length = self._getObjectLength(oid, value_serial)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.handler import EventHandler from neo.handler import EventHandler
from neo import protocol from neo import protocol
...@@ -35,7 +35,7 @@ class BaseMasterHandler(EventHandler): ...@@ -35,7 +35,7 @@ class BaseMasterHandler(EventHandler):
raise PrimaryFailure('re-election occurs') raise PrimaryFailure('re-election occurs')
def notifyClusterInformation(self, conn, state): def notifyClusterInformation(self, conn, state):
logging.warning('ignoring notify cluster information in %s' % neo.logging.warning('ignoring notify cluster information in %s' %
self.__class__.__name__) self.__class__.__name__)
def notifyLastOID(self, conn, oid): def notifyLastOID(self, conn, oid):
...@@ -48,7 +48,7 @@ class BaseMasterHandler(EventHandler): ...@@ -48,7 +48,7 @@ class BaseMasterHandler(EventHandler):
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
if uuid == self.app.uuid: if uuid == self.app.uuid:
# This is me, do what the master tell me # This is me, do what the master tell me
logging.info("I was told I'm %s" %(state)) neo.logging.info("I was told I'm %s" %(state))
if state in (NodeStates.DOWN, NodeStates.TEMPORARILY_DOWN, if state in (NodeStates.DOWN, NodeStates.TEMPORARILY_DOWN,
NodeStates.BROKEN): NodeStates.BROKEN):
conn.close() conn.close()
...@@ -57,7 +57,7 @@ class BaseMasterHandler(EventHandler): ...@@ -57,7 +57,7 @@ class BaseMasterHandler(EventHandler):
elif state == NodeStates.HIDDEN: elif state == NodeStates.HIDDEN:
raise OperationFailure raise OperationFailure
elif node_type == NodeTypes.CLIENT and state != NodeStates.RUNNING: elif node_type == NodeTypes.CLIENT and state != NodeStates.RUNNING:
logging.info('Notified of non-running client, abort (%r)', neo.logging.info('Notified of non-running client, abort (%r)',
dump(uuid)) dump(uuid))
self.app.tm.abortFor(uuid) self.app.tm.abortFor(uuid)
...@@ -86,14 +86,14 @@ class BaseClientAndStorageOperationHandler(EventHandler): ...@@ -86,14 +86,14 @@ class BaseClientAndStorageOperationHandler(EventHandler):
return return
o = self._askObject(oid, serial, tid) o = self._askObject(oid, serial, tid)
if o is None: if o is None:
logging.debug('oid = %s does not exist', dump(oid)) neo.logging.debug('oid = %s does not exist', dump(oid))
p = Errors.OidDoesNotExist(dump(oid)) p = Errors.OidDoesNotExist(dump(oid))
elif o is False: elif o is False:
logging.debug('oid = %s not found', dump(oid)) neo.logging.debug('oid = %s not found', dump(oid))
p = Errors.OidNotFound(dump(oid)) p = Errors.OidNotFound(dump(oid))
else: else:
serial, next_serial, compression, checksum, data, data_serial = o serial, next_serial, compression, checksum, data, data_serial = o
logging.debug('oid = %s, serial = %s, next_serial = %s', neo.logging.debug('oid = %s, serial = %s, next_serial = %s',
dump(oid), dump(serial), dump(next_serial)) dump(oid), dump(serial), dump(next_serial))
p = Packets.AnswerObject(oid, serial, next_serial, p = Packets.AnswerObject(oid, serial, next_serial,
compression, checksum, data, data_serial) compression, checksum, data, data_serial)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo import protocol from neo import protocol
from neo.util import dump from neo.util import dump
from neo.protocol import Packets, LockState, Errors from neo.protocol import Packets, LockState, Errors
...@@ -50,7 +50,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -50,7 +50,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
data_serial, tid, request_time): data_serial, tid, request_time):
if tid not in self.app.tm: if tid not in self.app.tm:
# transaction was aborted, cancel this event # transaction was aborted, cancel this event
logging.info('Forget store of %s:%s by %s delayed by %s', neo.logging.info('Forget store of %s:%s by %s delayed by %s',
dump(oid), dump(serial), dump(tid), dump(oid), dump(serial), dump(tid),
dump(self.app.tm.getLockingTID(oid))) dump(self.app.tm.getLockingTID(oid)))
# send an answer as the client side is waiting for it # send an answer as the client side is waiting for it
...@@ -71,7 +71,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -71,7 +71,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
if SLOW_STORE is not None: if SLOW_STORE is not None:
duration = time.time() - request_time duration = time.time() - request_time
if duration > SLOW_STORE: if duration > SLOW_STORE:
logging.info('StoreObject delay: %.02fs', duration) neo.logging.info('StoreObject delay: %.02fs', duration)
conn.answer(Packets.AnswerStoreObject(0, oid, serial)) conn.answer(Packets.AnswerStoreObject(0, oid, serial))
def askStoreObject(self, conn, oid, serial, def askStoreObject(self, conn, oid, serial,
...@@ -120,7 +120,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -120,7 +120,7 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def askHasLock(self, conn, tid, oid): def askHasLock(self, conn, tid, oid):
locking_tid = self.app.tm.getLockingTID(oid) locking_tid = self.app.tm.getLockingTID(oid)
logging.info('%r check lock of %r:%r', conn, dump(tid), dump(oid)) neo.logging.info('%r check lock of %r:%r', conn, dump(tid), dump(oid))
if locking_tid is None: if locking_tid is None:
state = LockState.NOT_LOCKED state = LockState.NOT_LOCKED
elif locking_tid is tid: elif locking_tid is tid:
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.storage.handlers import BaseMasterHandler from neo.storage.handlers import BaseMasterHandler
from neo.protocol import CellStates from neo.protocol import CellStates
...@@ -29,7 +29,7 @@ class HiddenHandler(BaseMasterHandler): ...@@ -29,7 +29,7 @@ class HiddenHandler(BaseMasterHandler):
app = self.app app = self.app
if ptid <= app.pt.getID(): if ptid <= app.pt.getID():
# Ignore this packet. # Ignore this packet.
logging.debug('ignoring older partition changes') neo.logging.debug('ignoring older partition changes')
return return
# update partition table in memory and the database # update partition table in memory and the database
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.handler import EventHandler from neo.handler import EventHandler
from neo.protocol import NodeTypes, Packets, NotReadyError from neo.protocol import NodeTypes, Packets, NotReadyError
...@@ -26,7 +26,7 @@ class IdentificationHandler(EventHandler): ...@@ -26,7 +26,7 @@ class IdentificationHandler(EventHandler):
""" Handler used for incoming connections during operation state """ """ Handler used for incoming connections during operation state """
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
logging.warning('A connection was lost during identification') neo.logging.warning('A connection was lost during identification')
def requestIdentification(self, conn, node_type, def requestIdentification(self, conn, node_type,
uuid, address, name): uuid, address, name):
...@@ -54,7 +54,8 @@ class IdentificationHandler(EventHandler): ...@@ -54,7 +54,8 @@ class IdentificationHandler(EventHandler):
from neo.storage.handlers.storage import StorageOperationHandler from neo.storage.handlers.storage import StorageOperationHandler
handler = StorageOperationHandler handler = StorageOperationHandler
if node is None: if node is None:
logging.error('reject an unknown storage node %s', dump(uuid)) neo.logging.error('reject an unknown storage node %s',
dump(uuid))
raise NotReadyError raise NotReadyError
else: else:
raise ProtocolError('reject non-client-or-storage node') raise ProtocolError('reject non-client-or-storage node')
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.storage.handlers import BaseMasterHandler from neo.storage.handlers import BaseMasterHandler
from neo import protocol from neo import protocol
...@@ -35,7 +35,7 @@ class InitializationHandler(BaseMasterHandler): ...@@ -35,7 +35,7 @@ class InitializationHandler(BaseMasterHandler):
pt.load(ptid, row_list, self.app.nm) pt.load(ptid, row_list, self.app.nm)
if not pt.filled(): if not pt.filled():
raise protocol.ProtocolError('Partial partition table received') raise protocol.ProtocolError('Partial partition table received')
logging.debug('Got the partition table :') neo.logging.debug('Got the partition table :')
self.app.pt.log() self.app.pt.log()
# Install the partition table into the database for persistency. # Install the partition table into the database for persistency.
cell_list = [] cell_list = []
...@@ -48,7 +48,7 @@ class InitializationHandler(BaseMasterHandler): ...@@ -48,7 +48,7 @@ class InitializationHandler(BaseMasterHandler):
unassigned_set.remove(offset) unassigned_set.remove(offset)
# delete objects database # delete objects database
if unassigned_set: if unassigned_set:
logging.debug('drop data for partitions %r' % unassigned_set) neo.logging.debug('drop data for partitions %r' % unassigned_set)
app.dm.dropPartitions(num_partitions, unassigned_set) app.dm.dropPartitions(num_partitions, unassigned_set)
app.dm.setPartitionTable(ptid, cell_list) app.dm.setPartitionTable(ptid, cell_list)
...@@ -66,4 +66,5 @@ class InitializationHandler(BaseMasterHandler): ...@@ -66,4 +66,5 @@ class InitializationHandler(BaseMasterHandler):
# packets in between (or even before asking for node information). # packets in between (or even before asking for node information).
# - this handler will be changed after receiving answerPartitionTable # - this handler will be changed after receiving answerPartitionTable
# and before handling the next packet # and before handling the next packet
logging.debug('ignoring notifyPartitionChanges during initialization') neo.logging.debug('ignoring notifyPartitionChanges during '\
'initialization')
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.util import dump from neo.util import dump
from neo.protocol import CellStates, Packets, ProtocolError from neo.protocol import CellStates, Packets, ProtocolError
from neo.storage.handlers import BaseMasterHandler from neo.storage.handlers import BaseMasterHandler
...@@ -36,7 +36,7 @@ class MasterOperationHandler(BaseMasterHandler): ...@@ -36,7 +36,7 @@ class MasterOperationHandler(BaseMasterHandler):
app = self.app app = self.app
if ptid <= app.pt.getID(): if ptid <= app.pt.getID():
# Ignore this packet. # Ignore this packet.
logging.debug('ignoring older partition changes') neo.logging.debug('ignoring older partition changes')
return return
# update partition table in memory and the database # update partition table in memory and the database
...@@ -67,8 +67,8 @@ class MasterOperationHandler(BaseMasterHandler): ...@@ -67,8 +67,8 @@ class MasterOperationHandler(BaseMasterHandler):
def askPack(self, conn, tid): def askPack(self, conn, tid):
app = self.app app = self.app
logging.info('Pack started, up to %s...', dump(tid)) neo.logging.info('Pack started, up to %s...', dump(tid))
app.dm.pack(tid, app.tm.updateObjectDataForPack) app.dm.pack(tid, app.tm.updateObjectDataForPack)
logging.info('Pack finished.') neo.logging.info('Pack finished.')
conn.answer(Packets.AnswerPack(True)) conn.answer(Packets.AnswerPack(True))
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.handler import EventHandler from neo.handler import EventHandler
from neo.protocol import Packets, ZERO_TID, ZERO_OID from neo.protocol import Packets, ZERO_TID, ZERO_OID
...@@ -82,11 +82,11 @@ class ReplicationHandler(EventHandler): ...@@ -82,11 +82,11 @@ class ReplicationHandler(EventHandler):
"""This class handles events for replications.""" """This class handles events for replications."""
def connectionLost(self, conn, new_state): def connectionLost(self, conn, new_state):
logging.error('replication is stopped due to a connection lost') neo.logging.error('replication is stopped due to a connection lost')
self.app.replicator.reset() self.app.replicator.reset()
def connectionFailed(self, conn): def connectionFailed(self, conn):
logging.error('replication is stopped due to connection failure') neo.logging.error('replication is stopped due to connection failure')
self.app.replicator.reset() self.app.replicator.reset()
def acceptIdentification(self, conn, node_type, def acceptIdentification(self, conn, node_type,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from neo.storage.handlers import BaseMasterHandler from neo.storage.handlers import BaseMasterHandler
from neo.protocol import Packets, Errors, ProtocolError from neo.protocol import Packets, Errors, ProtocolError
...@@ -48,7 +48,7 @@ class VerificationHandler(BaseMasterHandler): ...@@ -48,7 +48,7 @@ class VerificationHandler(BaseMasterHandler):
app = self.app app = self.app
if ptid <= app.pt.getID(): if ptid <= app.pt.getID():
# Ignore this packet. # Ignore this packet.
logging.debug('ignoring older partition changes') neo.logging.debug('ignoring older partition changes')
return return
# update partition table in memory and the database # update partition table in memory and the database
app.pt.update(ptid, cell_list, app.nm) app.pt.update(ptid, cell_list, app.nm)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo import logging import neo
from random import choice from random import choice
from neo.storage.handlers import replication from neo.storage.handlers import replication
...@@ -209,10 +209,10 @@ class Replicator(object): ...@@ -209,10 +209,10 @@ class Replicator(object):
try: try:
partition_list = self.critical_tid_dict.pop(uuid) partition_list = self.critical_tid_dict.pop(uuid)
except KeyError: except KeyError:
logging.debug("setCriticalTID raised KeyError for %s" % neo.logging.debug("setCriticalTID raised KeyError for %s" %
(dump(uuid), )) (dump(uuid), ))
else: else:
logging.debug('setting critical TID %s to %s', dump(tid), neo.logging.debug('setting critical TID %s to %s', dump(tid),
', '.join([str(p.getRID()) for p in partition_list])) ', '.join([str(p.getRID()) for p in partition_list]))
for partition in partition_list: for partition in partition_list:
partition.setCriticalTID(tid) partition.setCriticalTID(tid)
...@@ -227,7 +227,7 @@ class Replicator(object): ...@@ -227,7 +227,7 @@ class Replicator(object):
def setUnfinishedTIDList(self, tid_list): def setUnfinishedTIDList(self, tid_list):
"""This is a callback from MasterOperationHandler.""" """This is a callback from MasterOperationHandler."""
logging.debug('setting unfinished TIDs %s', neo.logging.debug('setting unfinished TIDs %s',
','.join([dump(tid) for tid in tid_list])) ','.join([dump(tid) for tid in tid_list]))
self.waiting_for_unfinished_tids = False self.waiting_for_unfinished_tids = False
self.unfinished_tid_list = tid_list self.unfinished_tid_list = tid_list
...@@ -248,13 +248,13 @@ class Replicator(object): ...@@ -248,13 +248,13 @@ class Replicator(object):
node = choice(node_list) node = choice(node_list)
except IndexError: except IndexError:
# Not operational. # Not operational.
logging.error('not operational', exc_info = 1) neo.logging.error('not operational', exc_info = 1)
self.current_partition = None self.current_partition = None
return return
addr = node.getAddress() addr = node.getAddress()
if addr is None: if addr is None:
logging.error("no address known for the selected node %s" % neo.logging.error("no address known for the selected node %s" %
(dump(node.getUUID()), )) (dump(node.getUUID()), ))
return return
if self.current_connection is not None: if self.current_connection is not None:
...@@ -302,19 +302,19 @@ class Replicator(object): ...@@ -302,19 +302,19 @@ class Replicator(object):
if self.replication_done and \ if self.replication_done and \
not self.current_connection.isPending(): not self.current_connection.isPending():
# finish a replication # finish a replication
logging.info('replication is done for %s' % neo.logging.info('replication is done for %s' %
(self.current_partition.getRID(), )) (self.current_partition.getRID(), ))
self._finishReplication() self._finishReplication()
return return
if self.waiting_for_unfinished_tids: if self.waiting_for_unfinished_tids:
# Still waiting. # Still waiting.
logging.debug('waiting for unfinished tids') neo.logging.debug('waiting for unfinished tids')
return return
if self.unfinished_tid_list is None: if self.unfinished_tid_list is None:
# Ask pending transactions. # Ask pending transactions.
logging.debug('asking unfinished tids') neo.logging.debug('asking unfinished tids')
self._askUnfinishedTIDs() self._askUnfinishedTIDs()
return return
...@@ -330,7 +330,7 @@ class Replicator(object): ...@@ -330,7 +330,7 @@ class Replicator(object):
else: else:
# Not yet. # Not yet.
self.unfinished_tid_list = None self.unfinished_tid_list = None
logging.debug('not ready yet') neo.logging.debug('not ready yet')
return return
self._startReplication() self._startReplication()
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from time import time from time import time
from neo import logging import neo
from neo.util import dump from neo.util import dump
...@@ -199,27 +199,27 @@ class TransactionManager(object): ...@@ -199,27 +199,27 @@ class TransactionManager(object):
# check if the object if locked # check if the object if locked
locking_tid = self._store_lock_dict.get(oid) locking_tid = self._store_lock_dict.get(oid)
if locking_tid == tid: if locking_tid == tid:
logging.info('Transaction %s storing %s more than once', dump(tid), neo.logging.info('Transaction %s storing %s more than once',
dump(oid)) dump(tid), dump(oid))
elif locking_tid is None: elif locking_tid is None:
# check if this is generated from the latest revision. # check if this is generated from the latest revision.
history_list = self._app.dm.getObjectHistory(oid) history_list = self._app.dm.getObjectHistory(oid)
if history_list and history_list[0][0] != serial: if history_list and history_list[0][0] != serial:
logging.info('Resolvable conflict on %r:%r', dump(oid), neo.logging.info('Resolvable conflict on %r:%r', dump(oid),
dump(tid)) dump(tid))
raise ConflictError(history_list[0][0]) raise ConflictError(history_list[0][0])
logging.info('Transaction %s storing %s', dump(tid), dump(oid)) neo.logging.info('Transaction %s storing %s', dump(tid), dump(oid))
self._store_lock_dict[oid] = tid self._store_lock_dict[oid] = tid
elif locking_tid < tid: elif locking_tid < tid:
# a previous transaction lock this object, retry later # a previous transaction lock this object, retry later
logging.info('Store delayed for %r:%r by %r', dump(oid), neo.logging.info('Store delayed for %r:%r by %r', dump(oid),
dump(tid), dump(locking_tid)) dump(tid), dump(locking_tid))
raise DelayedError raise DelayedError
else: else:
# If a newer transaction already locks this object, # If a newer transaction already locks this object,
# do not try to resolve a conflict, so return immediately. # do not try to resolve a conflict, so return immediately.
logging.info('Unresolvable conflict on %r:%r with %r', dump(oid), neo.logging.info('Unresolvable conflict on %r:%r with %r',
dump(tid), dump(locking_tid)) dump(oid), dump(tid), dump(locking_tid))
raise ConflictError(locking_tid) raise ConflictError(locking_tid)
# store object # store object
...@@ -275,15 +275,15 @@ class TransactionManager(object): ...@@ -275,15 +275,15 @@ class TransactionManager(object):
return oid in self._load_lock_dict return oid in self._load_lock_dict
def log(self): def log(self):
logging.info("Transactions:") neo.logging.info("Transactions:")
for txn in self._transaction_dict.values(): for txn in self._transaction_dict.values():
logging.info(' %r', txn) neo.logging.info(' %r', txn)
logging.info(' Read locks:') neo.logging.info(' Read locks:')
for oid, tid in self._load_lock_dict.items(): for oid, tid in self._load_lock_dict.items():
logging.info(' %r by %r', dump(oid), dump(tid)) neo.logging.info(' %r by %r', dump(oid), dump(tid))
logging.info(' Write locks:') neo.logging.info(' Write locks:')
for oid, tid in self._store_lock_dict.items(): for oid, tid in self._store_lock_dict.items():
logging.info(' %r by %r', dump(oid), dump(tid)) neo.logging.info(' %r by %r', dump(oid), dump(tid))
def updateObjectDataForPack(self, oid, orig_serial, new_serial, def updateObjectDataForPack(self, oid, orig_serial, new_serial,
getObjectData): getObjectData):
......
...@@ -20,7 +20,7 @@ import random ...@@ -20,7 +20,7 @@ import random
import unittest import unittest
import tempfile import tempfile
import MySQLdb import MySQLdb
from neo import logging import neo
from mock import Mock from mock import Mock
from neo import protocol from neo import protocol
from neo.protocol import Packets from neo.protocol import Packets
...@@ -394,7 +394,7 @@ connector_cpt = 0 ...@@ -394,7 +394,7 @@ connector_cpt = 0
class DoNothingConnector(Mock): class DoNothingConnector(Mock):
def __init__(self, s=None): def __init__(self, s=None):
logging.info("initializing connector") neo.logging.info("initializing connector")
self.desc = globals()['connector_cpt'] self.desc = globals()['connector_cpt']
globals()['connector_cpt'] = globals()['connector_cpt']+ 1 globals()['connector_cpt'] = globals()['connector_cpt']+ 1
self.packet_cpt = 0 self.packet_cpt = 0
......
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