Commit f6938688 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Yet more fixes with pyflakes.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@79 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e4d23152
import logging import logging
import os import os
from socket import inet_aton
from time import time, gmtime from time import time, gmtime
from struct import pack, unpack from struct import pack, unpack
from neo.config import ConfigurationManager from neo.config import ConfigurationManager
from neo.protocol import Packet, ProtocolError, \ from neo.protocol import Packet, \
RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, BROKEN_STATE, \ RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, BROKEN_STATE, \
INVALID_UUID, INVALID_OID, INVALID_TID, INVALID_PTID, CLIENT_NODE_TYPE INVALID_UUID, INVALID_OID, INVALID_TID, INVALID_PTID, CLIENT_NODE_TYPE
from neo.node import NodeManager, MasterNode, StorageNode, ClientNode from neo.node import NodeManager, MasterNode, StorageNode, ClientNode
from neo.event import EventManager from neo.event import EventManager
from neo.util import dump
from neo.connection import ListeningConnection, ClientConnection, ServerConnection from neo.connection import ListeningConnection, ClientConnection, ServerConnection
from neo.exception import ElectionFailure, PrimaryFailure, VerificationFailure, \ from neo.exception import ElectionFailure, PrimaryFailure, VerificationFailure, \
OperationFailure OperationFailure
...@@ -282,7 +280,7 @@ class Application(object): ...@@ -282,7 +280,7 @@ class Application(object):
p.notifyNodeInformation(c.getNextId(), node_list) p.notifyNodeInformation(c.getNextId(), node_list)
c.addPacket(p) c.addPacket(p)
else: else:
raise Runtime, 'unknown node type' raise RuntimeError('unknown node type')
def broadcastPartitionChanges(self, ptid, cell_list): def broadcastPartitionChanges(self, ptid, cell_list):
"""Broadcast a Notify Partition Changes packet.""" """Broadcast a Notify Partition Changes packet."""
...@@ -600,7 +598,8 @@ class Application(object): ...@@ -600,7 +598,8 @@ class Application(object):
# If anything changed, send the changes. # If anything changed, send the changes.
if cell_list: if cell_list:
app.broadcastPartitionChanges(self.getNextPartitionTableID(), cell_list) self.broadcastPartitionChanges(self.getNextPartitionTableID(),
cell_list)
def provideService(self): def provideService(self):
"""This is the normal mode for a primary master node. Handle transactions """This is the normal mode for a primary master node. Handle transactions
......
...@@ -6,7 +6,6 @@ from neo.master.handler import MasterEventHandler ...@@ -6,7 +6,6 @@ from neo.master.handler import MasterEventHandler
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.exception import ElectionFailure from neo.exception import ElectionFailure
from neo.protocol import Packet, INVALID_UUID from neo.protocol import Packet, INVALID_UUID
from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode from neo.node import MasterNode, StorageNode, ClientNode
class ElectionEventHandler(MasterEventHandler): class ElectionEventHandler(MasterEventHandler):
...@@ -259,7 +258,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -259,7 +258,7 @@ class ElectionEventHandler(MasterEventHandler):
app = self.app app = self.app
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
if node_type != MASTER_NODE: if node_type != MASTER_NODE_TYPE:
# No interest. # No interest.
continue continue
......
...@@ -2,12 +2,11 @@ import logging ...@@ -2,12 +2,11 @@ import logging
from neo.protocol import MASTER_NODE_TYPE, \ from neo.protocol import MASTER_NODE_TYPE, \
RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \ RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \
STORAGE_NODE_TYPE STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo.master.handler import MasterEventHandler from neo.master.handler import MasterEventHandler
from neo.exception import ElectionFailure from neo.exception import ElectionFailure
from neo.protocol import Packet, INVALID_UUID from neo.protocol import Packet, INVALID_UUID
from neo.node import ClientNode, StorageNode, MasterNode from neo.node import ClientNode, StorageNode, MasterNode
from neo.util import dump
class RecoveryEventHandler(MasterEventHandler): class RecoveryEventHandler(MasterEventHandler):
"""This class deals with events for a recovery phase.""" """This class deals with events for a recovery phase."""
...@@ -226,7 +225,7 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -226,7 +225,7 @@ class RecoveryEventHandler(MasterEventHandler):
app = self.app app = self.app
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
if node_type == CLIENT_NODE: if node_type == CLIENT_NODE_TYPE:
# No interest. # No interest.
continue continue
...@@ -301,7 +300,7 @@ class RecoveryEventHandler(MasterEventHandler): ...@@ -301,7 +300,7 @@ class RecoveryEventHandler(MasterEventHandler):
elif app.lptid == lptid and app.target_uuid is None: elif app.lptid == lptid and app.target_uuid is None:
app.target_uuid = uuid app.target_uuid = uuid
def handleAnswerPartitionTable(self, conn, packet, ptid, cell_list): def handleAnswerPartitionTable(self, conn, packet, ptid, row_list):
uuid = conn.getUUID() uuid = conn.getUUID()
if uuid is None: if uuid is None:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
......
...@@ -6,7 +6,7 @@ from neo.master.handler import MasterEventHandler ...@@ -6,7 +6,7 @@ from neo.master.handler import MasterEventHandler
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.exception import ElectionFailure, PrimaryFailure from neo.exception import ElectionFailure, PrimaryFailure
from neo.protocol import Packet, INVALID_UUID from neo.protocol import Packet, INVALID_UUID
from neo.util import dump from neo.node import MasterNode
class SecondaryEventHandler(MasterEventHandler): class SecondaryEventHandler(MasterEventHandler):
"""This class deals with events for a secondary master.""" """This class deals with events for a secondary master."""
......
import logging import logging
from neo.protocol import MASTER_NODE_TYPE, \ from neo.protocol import MASTER_NODE_TYPE, CLIENT_NODE_TYPE, \
RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE
from neo.master.handler import MasterEventHandler from neo.master.handler import MasterEventHandler
from neo.protocol import Packet, INVALID_UUID from neo.protocol import Packet, INVALID_UUID
from neo.exception import OperationFailure from neo.exception import OperationFailure, ElectionFailure
from neo.util import dump
from neo.node import ClientNode, StorageNode, MasterNode from neo.node import ClientNode, StorageNode, MasterNode
class FinishingTransaction(object): class FinishingTransaction(object):
...@@ -128,7 +127,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -128,7 +127,7 @@ class ServiceEventHandler(MasterEventHandler):
elif node_type == CLIENT_NODE_TYPE: elif node_type == CLIENT_NODE_TYPE:
node = ClientNode(uuid = uuid) node = ClientNode(uuid = uuid)
else: else:
node = StorageNode(server = address, uuid = uuid) node = StorageNode(server = addr, uuid = uuid)
app.nm.add(node) app.nm.add(node)
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
else: else:
...@@ -285,7 +284,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -285,7 +284,7 @@ class ServiceEventHandler(MasterEventHandler):
app = self.app app = self.app
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
if node_type == CLIENT_NODE: if node_type == CLIENT_NODE_TYPE:
# No interest. # No interest.
continue continue
......
import logging import logging
from neo.protocol import MASTER_NODE_TYPE, \ from neo.protocol import MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE
from neo.master.handler import MasterEventHandler from neo.master.handler import MasterEventHandler
from neo.exception import VerificationFailure from neo.exception import VerificationFailure, ElectionFailure
from neo.protocol import Packet, INVALID_UUID from neo.protocol import Packet, INVALID_UUID
from neo.util import dump from neo.util import dump
from neo.node import ClientNode, StorageNode, MasterNode from neo.node import ClientNode, StorageNode, MasterNode
...@@ -102,7 +102,7 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -102,7 +102,7 @@ class VerificationEventHandler(MasterEventHandler):
if node_type == MASTER_NODE_TYPE: if node_type == MASTER_NODE_TYPE:
node = MasterNode(server = addr, uuid = uuid) node = MasterNode(server = addr, uuid = uuid)
else: else:
node = StorageNode(server = address, uuid = uuid) node = StorageNode(server = addr, uuid = uuid)
app.nm.add(node) app.nm.add(node)
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
else: else:
...@@ -247,7 +247,7 @@ class VerificationEventHandler(MasterEventHandler): ...@@ -247,7 +247,7 @@ class VerificationEventHandler(MasterEventHandler):
app = self.app app = self.app
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
if node_type == CLIENT_NODE: if node_type == CLIENT_NODE_TYPE:
# No interest. # No interest.
continue continue
......
import logging import logging
import MySQLdb
import os import os
from time import time from time import time
from struct import pack, unpack from struct import unpack
from collections import deque from collections import deque
from neo.config import ConfigurationManager from neo.config import ConfigurationManager
from neo.protocol import Packet, ProtocolError, \ from neo.protocol import TEMPORARILY_DOWN_STATE, DOWN_STATE, BROKEN_STATE, \
RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, BROKEN_STATE, \ INVALID_UUID, INVALID_PTID
INVALID_UUID, INVALID_OID, INVALID_TID, INVALID_PTID
from neo.node import NodeManager, MasterNode, StorageNode, ClientNode from neo.node import NodeManager, MasterNode, StorageNode, ClientNode
from neo.event import EventManager from neo.event import EventManager
from neo.storage.mysqldb import MySQLDatabaseManager from neo.storage.mysqldb import MySQLDatabaseManager
from neo.util import dump from neo.connection import ListeningConnection, ClientConnection
from neo.connection import ListeningConnection, ClientConnection, ServerConnection
from neo.exception import OperationFailure, PrimaryFailure from neo.exception import OperationFailure, PrimaryFailure
from neo.pt import PartitionTable
from neo.storage.bootstrap import BootstrapEventHandler from neo.storage.bootstrap import BootstrapEventHandler
from neo.storage.verification import VerificationEventHandler from neo.storage.verification import VerificationEventHandler
from neo.storage.operation import OperationEventHandler from neo.storage.operation import OperationEventHandler
......
...@@ -3,7 +3,6 @@ import logging ...@@ -3,7 +3,6 @@ import logging
from neo.storage.handler import StorageEventHandler from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \ from neo.protocol import INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode from neo.node import MasterNode, StorageNode, ClientNode
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.protocol import Packet from neo.protocol import Packet
......
import logging import logging
from neo.handler import EventHandler from neo.handler import EventHandler
from neo.protocol import INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \ from neo.protocol import Packet, \
INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo.util import dump from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode from neo.node import MasterNode, StorageNode, ClientNode
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.exception import PrimaryFailure
class StorageEventHandler(EventHandler): class StorageEventHandler(EventHandler):
"""This class implements a generic part of the event handlers.""" """This class implements a generic part of the event handlers."""
...@@ -28,6 +30,7 @@ class StorageEventHandler(EventHandler): ...@@ -28,6 +30,7 @@ class StorageEventHandler(EventHandler):
def handleAskPrimaryMaster(self, conn, packet): def handleAskPrimaryMaster(self, conn, packet):
"""This should not be used in reality, because I am not a master """This should not be used in reality, because I am not a master
node. But? If someone likes to ask me, I can help.""" node. But? If someone likes to ask me, I can help."""
logging.info('asked a primary master node')
app = self.app app = self.app
if app.primary_master_node is not None: if app.primary_master_node is not None:
......
import logging import logging
from neo.storage.handler import StorageEventHandler from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_UUID, RUNNING_STATE, BROKEN_STATE, \ from neo.protocol import INVALID_UUID, INVALID_SERIAL, INVALID_TID, \
RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo.util import dump from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode from neo.node import MasterNode, StorageNode, ClientNode
...@@ -115,6 +116,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -115,6 +116,7 @@ class OperationEventHandler(StorageEventHandler):
if isinstance(conn, ClientConnection): if isinstance(conn, ClientConnection):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app
if name != app.name: if name != app.name:
logging.error('reject an alien cluster') logging.error('reject an alien cluster')
conn.addPacket(Packet().protocolError(packet.getId(), conn.addPacket(Packet().protocolError(packet.getId(),
...@@ -384,7 +386,7 @@ class OperationEventHandler(StorageEventHandler): ...@@ -384,7 +386,7 @@ class OperationEventHandler(StorageEventHandler):
return return
# Now store the object. # Now store the object.
t = app.transaction_dict.setdefault(tid, Transaction(uuid)) t = app.transaction_dict.setdefault(tid, TransactionInformation(uuid))
t.addObject(oid, compression, checksum, data) t.addObject(oid, compression, checksum, data)
conn.addPacket(Packet().answerStoreObject(packet.getId(), 0, conn.addPacket(Packet().answerStoreObject(packet.getId(), 0,
oid, serial)) oid, serial))
......
import logging import logging
from neo.storage.handler import StorageEventHandler from neo.storage.handler import StorageEventHandler
from neo.protocol import INVALID_OID, INVALID_TID, INVALID_UUID, \ from neo.protocol import INVALID_OID, INVALID_TID, \
RUNNING_STATE, BROKEN_STATE, \ RUNNING_STATE, BROKEN_STATE, TEMPORARILY_DOWN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \ MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, \
Packet Packet
from neo.util import dump from neo.util import dump
from neo.node import MasterNode, StorageNode, ClientNode from neo.node import MasterNode, StorageNode, ClientNode
from neo.connection import ClientConnection from neo.connection import ClientConnection
from neo.exception import PrimaryFailure from neo.exception import PrimaryFailure, OperationFailure
class VerificationEventHandler(StorageEventHandler): class VerificationEventHandler(StorageEventHandler):
"""This class deals with events for a verification phase.""" """This class deals with events for a verification phase."""
...@@ -48,6 +48,7 @@ class VerificationEventHandler(StorageEventHandler): ...@@ -48,6 +48,7 @@ class VerificationEventHandler(StorageEventHandler):
if isinstance(conn, ClientConnection): if isinstance(conn, ClientConnection):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
else: else:
app = self.app
if node_type != MASTER_NODE_TYPE: if node_type != MASTER_NODE_TYPE:
logging.info('reject a connection from a non-master') logging.info('reject a connection from a non-master')
conn.addPacket(Packet().notReady(packet.getId(), 'retry later')) conn.addPacket(Packet().notReady(packet.getId(), 'retry later'))
......
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