Commit fbbb07ea authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rename Node.getNodeType to Node.getType for consistency with None.getState.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1094 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d8a1d43d
......@@ -53,7 +53,7 @@ class AdminEventHandler(EventHandler):
def handleAskNodeList(self, conn, packet, node_type):
logging.info("ask node list for %s" %(node_type))
def node_filter(n):
return n.getNodeType() is node_type
return n.getType() is node_type
node_list = self.app.nm.getNodeList(node_filter)
node_information_list = []
for node in node_list:
......@@ -62,7 +62,7 @@ class AdminEventHandler(EventHandler):
except TypeError:
ip = "0.0.0.0"
port = 0
node_information_list.append((node.getNodeType(), (ip, port), node.getUUID(), node.getState()))
node_information_list.append((node.getType(), (ip, port), node.getUUID(), node.getState()))
p = protocol.answerNodeList(node_information_list)
conn.answer(p, packet.getId())
......
......@@ -42,7 +42,7 @@ def restrict_node_types(*node_types):
node = self.app.nm.getNodeByUUID(uuid)
if node is None:
raise protocol.UnexpectedPacketError
if node.getNodeType() not in node_types:
if node.getType() not in node_types:
raise protocol.UnexpectedPacketError
# all is ok, call the handler
handler(self, conn, packet, *args, **kwargs)
......
......@@ -279,7 +279,7 @@ class Application(object):
def broadcastNodeInformation(self, node):
"""Broadcast a Notify Node Information packet."""
logging.debug('broadcasting node information')
node_type = node.getNodeType()
node_type = node.getType()
state = node.getState()
uuid = node.getUUID()
......@@ -349,7 +349,7 @@ class Application(object):
address = n.getServer()
except TypeError:
address = None
node_list.append((n.getNodeType(), address, n.getUUID(), n.getState()))
node_list.append((n.getType(), address, n.getUUID(), n.getState()))
# Split the packet if too huge.
if len(node_list) == 10000:
conn.notify(protocol.notifyNodeInformation(node_list))
......
......@@ -72,7 +72,7 @@ class Node(object):
def getUUID(self):
return self.uuid
def getNodeType(self):
def getType(self):
raise NotImplementedError
def __str__(self):
......@@ -100,7 +100,7 @@ class Node(object):
class MasterNode(Node):
"""This class represents a master node."""
def getNodeType(self):
def getType(self):
return MASTER_NODE_TYPE
def isMaster(self):
......@@ -110,7 +110,7 @@ class MasterNode(Node):
class StorageNode(Node):
"""This class represents a storage node."""
def getNodeType(self):
def getType(self):
return STORAGE_NODE_TYPE
def isStorage(self):
......@@ -120,7 +120,7 @@ class StorageNode(Node):
class ClientNode(Node):
"""This class represents a client node."""
def getNodeType(self):
def getType(self):
return CLIENT_NODE_TYPE
def isClient(self):
......@@ -130,7 +130,7 @@ class ClientNode(Node):
class AdminNode(Node):
"""This class represents an admin node."""
def getNodeType(self):
def getType(self):
return ADMIN_NODE_TYPE
def isAdmin(self):
......@@ -262,7 +262,7 @@ class NodeManager(object):
for uuid, node in sorted(self.uuid_dict.items()):
args = (
dump(uuid),
node_type_dict[node.getNodeType()],
node_type_dict[node.getType()],
node_state_dict[node.getState()]
)
logging.debug('nm: %s : %s/%s' % args)
......@@ -94,7 +94,7 @@ class ClientHandlerTests(NeoTestBase):
storage_ip = '127.0.0.1'
storage_port = 10011
fake_storage_node_uuid = self.getNewUUID()
fake_storage_node = Mock({'getUUID': fake_storage_node_uuid, 'getServer': (storage_ip, storage_port), 'getNodeType': STORAGE_NODE_TYPE})
fake_storage_node = Mock({'getUUID': fake_storage_node_uuid, 'getServer': (storage_ip, storage_port), 'getType': STORAGE_NODE_TYPE})
master_node_next_packet_id = 1
class App:
primary_master_node = Mock({'getUUID': self.getNewUUID()})
......@@ -276,7 +276,7 @@ class ClientHandlerTests(NeoTestBase):
# Master node handler
def test_nonMasterAnswerPrimaryMaster(self):
for node_type in (CLIENT_NODE_TYPE, STORAGE_NODE_TYPE):
node = Mock({'getNodeType': node_type})
node = Mock({'getType': node_type})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': None, 'add': None})
trying_master_node = None
......@@ -289,7 +289,7 @@ class ClientHandlerTests(NeoTestBase):
self.assertEqual(len(app.nm.mockGetNamedCalls('add')), 0)
def test_unknownNodeAnswerPrimaryMaster(self):
node = Mock({'getNodeType': MASTER_NODE_TYPE})
node = Mock({'getType': MASTER_NODE_TYPE})
class App:
nm = Mock({'getNodeByServer': None, 'add': None})
primary_master_node = None
......@@ -314,7 +314,7 @@ class ClientHandlerTests(NeoTestBase):
self.assertEquals(app.primary_master_node, None)
def test_knownNodeUnknownUUIDNodeAnswerPrimaryMaster(self):
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': None, 'setUUID': None})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': None, 'setUUID': None})
class App:
nm = Mock({'getNodeByServer': node, 'add': None})
primary_master_node = None
......@@ -341,7 +341,7 @@ class ClientHandlerTests(NeoTestBase):
def test_knownNodeKnownUUIDNodeAnswerPrimaryMaster(self):
test_node_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByServer': node, 'add': None})
primary_master_node = None
......@@ -375,7 +375,7 @@ class ClientHandlerTests(NeoTestBase):
while test_primary_node_uuid == test_node_uuid:
test_primary_node_uuid = self.getNewUUID()
test_primary_master_node = Mock({'getUUID': test_primary_node_uuid})
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': node, 'add': None})
primary_master_node = test_primary_master_node
......@@ -398,7 +398,7 @@ class ClientHandlerTests(NeoTestBase):
def test_alreadySamePrimaryAnswerPrimaryMaster(self):
test_node_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': node, 'add': None})
primary_master_node = node
......@@ -415,7 +415,7 @@ class ClientHandlerTests(NeoTestBase):
test_primary_node_uuid = test_node_uuid
while test_primary_node_uuid == test_node_uuid:
test_primary_node_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': None, 'getNodeByServer': node, 'add': None})
primary_master_node = None
......@@ -433,7 +433,7 @@ class ClientHandlerTests(NeoTestBase):
def test_AnswerPrimaryMaster(self):
test_node_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_node_uuid, 'setUUID': None})
class App:
nm = Mock({'getNodeByUUID': node, 'getNodeByServer': node, 'add': None})
primary_master_node = None
......@@ -462,7 +462,7 @@ class ClientHandlerTests(NeoTestBase):
def test_nonMasterSendPartitionTable(self):
for node_type in (CLIENT_NODE_TYPE, STORAGE_NODE_TYPE):
node = Mock({'getNodeType': node_type})
node = Mock({'getType': node_type})
class App:
nm = Mock({'getNodeByUUID': node})
pt = Mock()
......@@ -475,7 +475,7 @@ class ClientHandlerTests(NeoTestBase):
self.assertEquals(len(app.pt.mockGetNamedCalls('removeCell')), 0)
def test_newSendPartitionTable(self):
node = Mock({'getNodeType': MASTER_NODE_TYPE})
node = Mock({'getType': MASTER_NODE_TYPE})
test_ptid = 0
class App:
nm = Mock({'getNodeByUUID': node})
......@@ -490,7 +490,7 @@ class ClientHandlerTests(NeoTestBase):
self.assertEquals(len(app.pt.mockGetNamedCalls('clear')), 1)
def test_unknownNodeSendPartitionTable(self):
test_node = Mock({'getNodeType': MASTER_NODE_TYPE})
test_node = Mock({'getType': MASTER_NODE_TYPE})
test_ptid = 0
class App:
nm = Mock({'getNodeByUUID': ReturnValues(test_node, None), 'add': None})
......@@ -515,7 +515,7 @@ class ClientHandlerTests(NeoTestBase):
test_row_list[0][1][0][1])
def test_knownNodeSendPartitionTable(self):
test_node = Mock({'getNodeType': MASTER_NODE_TYPE})
test_node = Mock({'getType': MASTER_NODE_TYPE})
test_ptid = 0
class App:
nm = Mock({'getNodeByUUID': test_node, 'add': None})
......@@ -539,7 +539,7 @@ class ClientHandlerTests(NeoTestBase):
def test_nonMasterNotifyNodeInformation(self):
for node_type in (CLIENT_NODE_TYPE, STORAGE_NODE_TYPE):
test_master_uuid = self.getNewUUID()
node = Mock({'getNodeType': node_type})
node = Mock({'getType': node_type})
class App:
nm = Mock({'getNodeByUUID': node})
app = App()
......@@ -553,7 +553,7 @@ class ClientHandlerTests(NeoTestBase):
# by making a valid call with a non-iterable parameter given as
# node_list value.
test_master_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE})
node = Mock({'getType': MASTER_NODE_TYPE})
class App:
nm = Mock({'getNodeByUUID': node})
app = App()
......@@ -567,7 +567,7 @@ class ClientHandlerTests(NeoTestBase):
INVALID_UUID, test_node[4])
test_node_list = [test_node, invalid_uid_test_node]
test_master_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE})
node = Mock({'getType': MASTER_NODE_TYPE})
if getNodeByUUID is not MARKER:
getNodeByUUID = ReturnValues(node, getNodeByUUID)
class App:
......@@ -656,7 +656,7 @@ class ClientHandlerTests(NeoTestBase):
def test_nonMasterNotifyPartitionChanges(self):
for node_type in (CLIENT_NODE_TYPE, STORAGE_NODE_TYPE):
test_master_uuid = self.getNewUUID()
node = Mock({'getNodeType': node_type, 'getUUID': test_master_uuid})
node = Mock({'getType': node_type, 'getUUID': test_master_uuid})
class App:
nm = Mock({'getNodeByUUID': node})
pt = Mock()
......@@ -671,7 +671,7 @@ class ClientHandlerTests(NeoTestBase):
self.assertEquals(len(app.pt.mockGetNamedCalls('removeCell')), 0)
def test_noPrimaryMasterNotifyPartitionChanges(self):
node = Mock({'getNodeType': MASTER_NODE_TYPE})
node = Mock({'getType': MASTER_NODE_TYPE})
class App:
nm = Mock({'getNodeByUUID': node})
pt = Mock()
......@@ -690,7 +690,7 @@ class ClientHandlerTests(NeoTestBase):
test_sender_uuid = test_master_uuid
while test_sender_uuid == test_master_uuid:
test_sender_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE})
node = Mock({'getType': MASTER_NODE_TYPE})
test_master_node = Mock({'getUUID': test_master_uuid})
class App:
nm = Mock({'getNodeByUUID': node})
......@@ -707,7 +707,7 @@ class ClientHandlerTests(NeoTestBase):
def test_ignoreOutdatedPTIDNotifyPartitionChanges(self):
test_master_uuid = self.getNewUUID()
node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_master_uuid})
node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_master_uuid})
test_ptid = 1
class App:
nm = Mock({'getNodeByUUID': node})
......@@ -725,7 +725,7 @@ class ClientHandlerTests(NeoTestBase):
def test_unknownNodeNotifyPartitionChanges(self):
test_master_uuid = self.getNewUUID()
test_node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': test_master_uuid})
test_node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': test_master_uuid})
test_ptid = 1
class App:
nm = Mock({'getNodeByUUID': ReturnValues(None)})
......@@ -756,7 +756,7 @@ class ClientHandlerTests(NeoTestBase):
test_ptid = 1
uuid1, uuid2 = self.getNewUUID(), self.getNewUUID()
uuid3, uuid4 = self.getNewUUID(), self.getNewUUID()
test_node = Mock({'getNodeType': MASTER_NODE_TYPE, 'getUUID': uuid1})
test_node = Mock({'getType': MASTER_NODE_TYPE, 'getUUID': uuid1})
class App:
nm = Mock({'getNodeByUUID': ReturnValues(test_node, None, None, None), 'add': None})
pt = Mock({'setCell': None})
......
......@@ -62,10 +62,10 @@ class HandlerDecoratorsTests(NeoTestBase):
uuid = self.getNewUUID()
packet = Mock({})
handler = Mock({})
storage = Mock({'getNodeType': STORAGE_NODE_TYPE})
master = Mock({'getNodeType': MASTER_NODE_TYPE})
client = Mock({'getNodeType': CLIENT_NODE_TYPE})
admin = Mock({'getNodeType': ADMIN_NODE_TYPE})
storage = Mock({'getType': STORAGE_NODE_TYPE})
master = Mock({'getType': MASTER_NODE_TYPE})
client = Mock({'getType': CLIENT_NODE_TYPE})
admin = Mock({'getType': ADMIN_NODE_TYPE})
nodes = (storage, master, client, admin)
# no uuid -> fail
wrapped = decorators.restrict_node_types()(handler)
......
......@@ -50,7 +50,7 @@ class NodesTests(unittest.TestCase):
self.assertEqual(node.getState(), RUNNING_STATE)
self.assertEqual(node.getServer(), server)
self.assertEqual(node.getUUID(), uuid)
self.assertRaises(NotImplementedError, node.getNodeType)
self.assertRaises(NotImplementedError, node.getType)
self.assertNotEqual(node.getLastStateChange(), None)
last_change = node.getLastStateChange()
self.failUnless(isinstance(last_change, float))
......@@ -105,7 +105,7 @@ class NodesTests(unittest.TestCase):
self.assertEqual(node.getState(), RUNNING_STATE)
self.assertEqual(node.getServer(), server)
self.assertEqual(node.getUUID(), uuid)
self.assertEqual(MASTER_NODE_TYPE, node.getNodeType())
self.assertEqual(MASTER_NODE_TYPE, node.getType())
def test_02_storage_node(self):
server = ("127.0.0.1", 10000)
......@@ -117,7 +117,7 @@ class NodesTests(unittest.TestCase):
self.assertEqual(node.getState(), RUNNING_STATE)
self.assertEqual(node.getServer(), server)
self.assertEqual(node.getUUID(), uuid)
self.assertEqual(STORAGE_NODE_TYPE, node.getNodeType())
self.assertEqual(STORAGE_NODE_TYPE, node.getType())
def test_04_client_node(self):
server = ("127.0.0.1", 10000)
......@@ -129,7 +129,7 @@ class NodesTests(unittest.TestCase):
self.assertEqual(node.getState(), RUNNING_STATE)
self.assertEqual(node.getServer(), server)
self.assertEqual(node.getUUID(), uuid)
self.assertEqual(CLIENT_NODE_TYPE, node.getNodeType())
self.assertEqual(CLIENT_NODE_TYPE, node.getType())
def test_05_node_manager(self):
......
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