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