Commit 87b0405e authored by Grégory Wisniewski's avatar Grégory Wisniewski

Suffix cluster state definitions with '_CLUSTER_STATE'


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1242 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a6d13d0e
...@@ -23,7 +23,7 @@ from struct import pack, unpack ...@@ -23,7 +23,7 @@ from struct import pack, unpack
from neo.config import ConfigurationManager from neo.config import ConfigurationManager
from neo import protocol from neo import protocol
from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \ from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \
UUID_NAMESPACES, BOOTING, INVALID_UUID UUID_NAMESPACES, BOOTING_CLUSTER_STATE, INVALID_UUID
from neo.node import NodeManager, MasterNode, StorageNode, ClientNode, AdminNode from neo.node import NodeManager, MasterNode, StorageNode, ClientNode, AdminNode
from neo.event import EventManager from neo.event import EventManager
from neo.connection import ListeningConnection, ClientConnection, ServerConnection from neo.connection import ListeningConnection, ClientConnection, ServerConnection
...@@ -111,7 +111,7 @@ class Application(object): ...@@ -111,7 +111,7 @@ class Application(object):
self.listening_conn = ListeningConnection(self.em, None, self.listening_conn = ListeningConnection(self.em, None,
addr = self.server, connector_handler = self.connector_handler) addr = self.server, connector_handler = self.connector_handler)
self.cluster_state = BOOTING self.cluster_state = BOOTING_CLUSTER_STATE
# Start the election of a primary master node. # Start the election of a primary master node.
self.electPrimary() self.electPrimary()
...@@ -397,7 +397,7 @@ class Application(object): ...@@ -397,7 +397,7 @@ class Application(object):
partition table or make a new table from scratch, if this is the first time.""" partition table or make a new table from scratch, if this is the first time."""
logging.info('begin the recovery of the status') logging.info('begin the recovery of the status')
self.changeClusterState(protocol.RECOVERING) self.changeClusterState(protocol.RECOVERING_CLUSTER_STATE)
em = self.em em = self.em
self.loid = None self.loid = None
...@@ -406,7 +406,7 @@ class Application(object): ...@@ -406,7 +406,7 @@ class Application(object):
self.target_uuid = None self.target_uuid = None
# collect the last partition table available # collect the last partition table available
while self.cluster_state == protocol.RECOVERING: while self.cluster_state == protocol.RECOVERING_CLUSTER_STATE:
em.poll(1) em.poll(1)
logging.info('startup allowed') logging.info('startup allowed')
...@@ -495,7 +495,7 @@ class Application(object): ...@@ -495,7 +495,7 @@ class Application(object):
"""Verify the data in storage nodes and clean them up, if necessary.""" """Verify the data in storage nodes and clean them up, if necessary."""
em, nm = self.em, self.nm em, nm = self.em, self.nm
self.changeClusterState(protocol.VERIFYING) self.changeClusterState(protocol.VERIFYING_CLUSTER_STATE)
# wait for any missing node # wait for any missing node
logging.debug('waiting for the cluster to be operational') logging.debug('waiting for the cluster to be operational')
...@@ -578,7 +578,7 @@ class Application(object): ...@@ -578,7 +578,7 @@ class Application(object):
em = self.em em = self.em
nm = self.nm nm = self.nm
self.changeClusterState(protocol.RUNNING) self.changeClusterState(protocol.RUNNING_CLUSTER_STATE)
# This dictionary is used to hold information on transactions being finished. # This dictionary is used to hold information on transactions being finished.
self.finishing_transaction_dict = {} self.finishing_transaction_dict = {}
...@@ -669,13 +669,13 @@ class Application(object): ...@@ -669,13 +669,13 @@ class Application(object):
nm, em = self.nm, self.em nm, em = self.nm, self.em
# select the storage handler # select the storage handler
if state == protocol.BOOTING: if state == protocol.BOOTING_CLUSTER_STATE:
storage_handler = recovery.RecoveryHandler storage_handler = recovery.RecoveryHandler
elif state == protocol.RECOVERING: elif state == protocol.RECOVERING_CLUSTER_STATE:
storage_handler = recovery.RecoveryHandler storage_handler = recovery.RecoveryHandler
elif state == protocol.VERIFYING: elif state == protocol.VERIFYING_CLUSTER_STATE:
storage_handler = verification.VerificationHandler storage_handler = verification.VerificationHandler
elif state == protocol.RUNNING: elif state == protocol.RUNNING_CLUSTER_STATE:
storage_handler = storage.StorageServiceHandler storage_handler = storage.StorageServiceHandler
else: else:
RuntimeError('Unexpected node type') RuntimeError('Unexpected node type')
...@@ -692,7 +692,7 @@ class Application(object): ...@@ -692,7 +692,7 @@ class Application(object):
# those node types keep their own handler # those node types keep their own handler
continue continue
if node.isClient(): if node.isClient():
if state != protocol.RUNNING: if state != protocol.RUNNING_CLUSTER_STATE:
conn.close() conn.close()
handler = client.ClientServiceHandler handler = client.ClientServiceHandler
elif node.isStorage(): elif node.isStorage():
...@@ -766,7 +766,7 @@ class Application(object): ...@@ -766,7 +766,7 @@ class Application(object):
while 1: while 1:
self.em.poll(1) self.em.poll(1)
if len(self.finishing_transaction_dict) == 0: if len(self.finishing_transaction_dict) == 0:
if self.cluster_state == protocol.RUNNING: if self.cluster_state == protocol.RUNNING_CLUSTER_STATE:
sys.exit("Application has been asked to shut down") sys.exit("Application has been asked to shut down")
else: else:
# no more transaction, ask clients to shutdown # no more transaction, ask clients to shutdown
...@@ -791,12 +791,12 @@ class Application(object): ...@@ -791,12 +791,12 @@ class Application(object):
def identifyStorageNode(self, uuid, node): def identifyStorageNode(self, uuid, node):
state = protocol.RUNNING_STATE state = protocol.RUNNING_STATE
handler = None handler = None
if self.cluster_state == protocol.RECOVERING: if self.cluster_state == protocol.RECOVERING_CLUSTER_STATE:
if uuid is None: if uuid is None:
logging.info('reject empty storage node') logging.info('reject empty storage node')
raise protocol.NotReadyError raise protocol.NotReadyError
handler = recovery.RecoveryHandler handler = recovery.RecoveryHandler
elif self.cluster_state == protocol.VERIFYING: elif self.cluster_state == protocol.VERIFYING_CLUSTER_STATE:
if uuid is None or node is None: if uuid is None or node is None:
# if node is unknown, it has been forget when the current # if node is unknown, it has been forget when the current
# partition was validated by the admin # partition was validated by the admin
...@@ -805,12 +805,12 @@ class Application(object): ...@@ -805,12 +805,12 @@ class Application(object):
# conflicting UUID are rejected in the identification handler. # conflicting UUID are rejected in the identification handler.
state = protocol.PENDING_STATE state = protocol.PENDING_STATE
handler = verification.VerificationHandler handler = verification.VerificationHandler
elif self.cluster_state == protocol.RUNNING: elif self.cluster_state == protocol.RUNNING_CLUSTER_STATE:
if uuid is None or node is None: if uuid is None or node is None:
# same as for verification # same as for verification
state = protocol.PENDING_STATE state = protocol.PENDING_STATE
handler = storage.StorageServiceHandler handler = storage.StorageServiceHandler
elif self.cluster_state == protocol.STOPPING: elif self.cluster_state == protocol.STOPPING_CLUSTER_STATE:
raise protocol.NotReadyError raise protocol.NotReadyError
else: else:
raise RuntimeError('unhandled cluster state') raise RuntimeError('unhandled cluster state')
...@@ -836,7 +836,7 @@ class Application(object): ...@@ -836,7 +836,7 @@ class Application(object):
logging.info('Accept a master %s' % dump(uuid)) logging.info('Accept a master %s' % dump(uuid))
elif node_type == protocol.CLIENT_NODE_TYPE: elif node_type == protocol.CLIENT_NODE_TYPE:
# refuse any client before running # refuse any client before running
if self.cluster_state != protocol.RUNNING: if self.cluster_state != protocol.RUNNING_CLUSTER_STATE:
logging.info('Reject a connection from a client') logging.info('Reject a connection from a client')
raise protocol.NotReadyError raise protocol.NotReadyError
klass = ClientNode klass = ClientNode
......
...@@ -20,7 +20,7 @@ from neo import logging ...@@ -20,7 +20,7 @@ from neo import logging
from neo import protocol from neo import protocol
from neo.master.handlers import MasterHandler from neo.master.handlers import MasterHandler
from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \ from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \
HIDDEN_STATE, PENDING_STATE, RUNNING HIDDEN_STATE, PENDING_STATE, RUNNING_CLUSTER_STATE
from neo.util import dump from neo.util import dump
class AdministrationHandler(MasterHandler): class AdministrationHandler(MasterHandler):
...@@ -39,7 +39,7 @@ class AdministrationHandler(MasterHandler): ...@@ -39,7 +39,7 @@ class AdministrationHandler(MasterHandler):
self.app.changeClusterState(state) self.app.changeClusterState(state)
p = protocol.noError('cluster state changed') p = protocol.noError('cluster state changed')
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
if state == protocol.STOPPING: if state == protocol.STOPPING_CLUSTER_STATE:
self.app.cluster_state = state self.app.cluster_state = state
self.app.shutdown() self.app.shutdown()
......
...@@ -154,7 +154,7 @@ class TerminalNeoCTL(object): ...@@ -154,7 +154,7 @@ class TerminalNeoCTL(object):
""" """
Starts cluster operation after a startup. Starts cluster operation after a startup.
Equivalent to: Equivalent to:
set cluster VERIFYING set cluster VERIFYING_CLUSTER_STATE
""" """
assert len(params) == 0 assert len(params) == 0
self.neoctl.startCluster() self.neoctl.startCluster()
......
...@@ -126,7 +126,7 @@ class NeoCTL(object): ...@@ -126,7 +126,7 @@ class NeoCTL(object):
""" """
Set cluster into "verifying" state. Set cluster into "verifying" state.
""" """
self.setClusterState(protocol.VERIFYING) self.setClusterState(protocol.VERIFYING_CLUSTER_STATE)
def dropNode(self, node): def dropNode(self, node):
""" """
......
...@@ -316,11 +316,11 @@ error_codes = Enum({ ...@@ -316,11 +316,11 @@ error_codes = Enum({
# Cluster states # Cluster states
cluster_states = Enum({ cluster_states = Enum({
'BOOTING': 1, 'BOOTING_CLUSTER_STATE': 1,
'RECOVERING': 2, 'RECOVERING_CLUSTER_STATE': 2,
'VERIFYING': 3, 'VERIFYING_CLUSTER_STATE': 3,
'RUNNING': 4, 'RUNNING_CLUSTER_STATE': 4,
'STOPPING': 5, 'STOPPING_CLUSTER_STATE': 5,
}) })
# Node types. # Node types.
......
...@@ -456,13 +456,13 @@ class NEOCluster(object): ...@@ -456,13 +456,13 @@ class NEOCluster(object):
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, timeout, delay)
def expectClusterRecovering(self, timeout=0, delay=1): def expectClusterRecovering(self, timeout=0, delay=1):
self.expectClusterState(protocol.RECOVERING) self.expectClusterState(protocol.RECOVERING_CLUSTER_STATE)
def expectClusterVeryfing(self, timeout=0, delay=1): def expectClusterVeryfing(self, timeout=0, delay=1):
self.expectClusterState(protocol.VERIFYING) self.expectClusterState(protocol.VERIFYING_CLUSTER_STATE)
def expectClusterRunning(self, timeout=0, delay=1): def expectClusterRunning(self, timeout=0, delay=1):
self.expectClusterState(protocol.RUNNING) self.expectClusterState(protocol.RUNNING_CLUSTER_STATE)
def __del__(self): def __del__(self):
if self.cleanup_on_delete: if self.cleanup_on_delete:
......
...@@ -27,9 +27,9 @@ class ClusterTests(unittest.TestCase): ...@@ -27,9 +27,9 @@ class ClusterTests(unittest.TestCase):
neo.setupDB() neo.setupDB()
neo.start() neo.start()
try: try:
self.assertEqual(neoctl.getClusterState(), protocol.RUNNING) self.assertEqual(neoctl.getClusterState(), protocol.RUNNING_CLUSTER_STATE)
neo.killStorage() neo.killStorage()
neo.expectClusterState(protocol.VERIFYING) neo.expectClusterState(protocol.VERIFYING_CLUSTER_STATE)
finally: finally:
neo.stop() neo.stop()
...@@ -40,9 +40,9 @@ class ClusterTests(unittest.TestCase): ...@@ -40,9 +40,9 @@ class ClusterTests(unittest.TestCase):
neo.setupDB() neo.setupDB()
neo.start() neo.start()
try: try:
self.assertEqual(neoctl.getClusterState(), protocol.RUNNING) self.assertEqual(neoctl.getClusterState(), protocol.RUNNING_CLUSTER_STATE)
neo.killStorage() neo.killStorage()
neo.expectClusterState(protocol.VERIFYING) neo.expectClusterState(protocol.VERIFYING_CLUSTER_STATE)
finally: finally:
neo.stop() neo.stop()
...@@ -53,9 +53,9 @@ class ClusterTests(unittest.TestCase): ...@@ -53,9 +53,9 @@ class ClusterTests(unittest.TestCase):
neo.setupDB() neo.setupDB()
neo.start() neo.start()
try: try:
self.assertEqual(neoctl.getClusterState(), protocol.RUNNING) self.assertEqual(neoctl.getClusterState(), protocol.RUNNING_CLUSTER_STATE)
neo.killStorage() neo.killStorage()
neo.expectClusterState(protocol.RUNNING) neo.expectClusterState(protocol.RUNNING_CLUSTER_STATE)
finally: finally:
neo.stop() neo.stop()
......
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