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
from neo.util import dump
from neo.connector import getConnectorHandler
REQUIRED_NODE_NUMBER = 1
class Application(object):
"""The master node application."""
......@@ -276,6 +278,7 @@ class Application(object):
conn.close()
bootstrap = False
# XXX: should accept a node list and send at most one packet per peer
def broadcastNodeInformation(self, node):
"""Broadcast a Notify Node Information packet."""
logging.debug('broadcasting node information')
......@@ -369,18 +372,19 @@ class Application(object):
nm, em, pt = self.nm, self.em, self.pt
logging.debug('creating a new partition table, wait for a storage node')
# wait for some empty storage nodes, their are accepted
while len(nm.getStorageNodeList()) == 0:
while len(nm.getStorageNodeList()) < REQUIRED_NODE_NUMBER:
em.poll(1)
# take the first node available
node = nm.getStorageNodeList()[0]
node.setState(protocol.RUNNING_STATE)
self.broadcastNodeInformation(node)
node_list = nm.getStorageNodeList()[:REQUIRED_NODE_NUMBER]
for node in node_list:
node.setState(protocol.RUNNING_STATE)
self.broadcastNodeInformation(node)
# resert IDs generators
self.loid = '\0' * 8
self.ltid = '\0' * 8
# build the partition with this node
pt.setID(pack('!Q', 1))
pt.make([node])
pt.make(node_list)
def recoverStatus(self):
"""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