Commit 5912c7f7 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Allow create a new cluster with more than one storage node, this is controlled

by the REQUIRED_NODE_NUMBER definition, and keep the default with one node.
Add a XXX about broadcastNodeInformation possible improvement.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1120 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c31dc434
...@@ -36,6 +36,8 @@ from neo.master.pt import PartitionTable ...@@ -36,6 +36,8 @@ from neo.master.pt import PartitionTable
from neo.util import dump from neo.util import dump
from neo.connector import getConnectorHandler from neo.connector import getConnectorHandler
REQUIRED_NODE_NUMBER = 1
class Application(object): class Application(object):
"""The master node application.""" """The master node application."""
...@@ -276,6 +278,7 @@ class Application(object): ...@@ -276,6 +278,7 @@ class Application(object):
conn.close() conn.close()
bootstrap = False bootstrap = False
# XXX: should accept a node list and send at most one packet per peer
def broadcastNodeInformation(self, node): def broadcastNodeInformation(self, node):
"""Broadcast a Notify Node Information packet.""" """Broadcast a Notify Node Information packet."""
logging.debug('broadcasting node information') logging.debug('broadcasting node information')
...@@ -369,10 +372,11 @@ class Application(object): ...@@ -369,10 +372,11 @@ class Application(object):
nm, em, pt = self.nm, self.em, self.pt nm, em, pt = self.nm, self.em, self.pt
logging.debug('creating a new partition table, wait for a storage node') 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.getStorageNodeList()) == 0: while len(nm.getStorageNodeList()) < REQUIRED_NODE_NUMBER:
em.poll(1) em.poll(1)
# take the first node available # take the first node available
node = nm.getStorageNodeList()[0] node_list = nm.getStorageNodeList()[:REQUIRED_NODE_NUMBER]
for node in node_list:
node.setState(protocol.RUNNING_STATE) node.setState(protocol.RUNNING_STATE)
self.broadcastNodeInformation(node) self.broadcastNodeInformation(node)
# resert IDs generators # resert IDs generators
...@@ -380,7 +384,7 @@ class Application(object): ...@@ -380,7 +384,7 @@ class Application(object):
self.ltid = '\0' * 8 self.ltid = '\0' * 8
# build the partition with this node # build the partition with this node
pt.setID(pack('!Q', 1)) pt.setID(pack('!Q', 1))
pt.make([node]) pt.make(node_list)
def recoverStatus(self): def recoverStatus(self):
"""Recover the status about the cluster. Obtain the last OID, the last TID, """Recover the status about the cluster. Obtain the last OID, the last TID,
......
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