Commit 156ef1ef authored by Vincent Pelletier's avatar Vincent Pelletier

Increase value sanity checks for cell and node states.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@338 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 445bc004
...@@ -19,7 +19,7 @@ from time import time ...@@ -19,7 +19,7 @@ from time import time
import logging import logging
from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, BROKEN_STATE, \ from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, BROKEN_STATE, \
MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE MASTER_NODE_TYPE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE, VALID_NODE_STATE_LIST
from neo.util import dump from neo.util import dump
class Node(object): class Node(object):
...@@ -42,6 +42,7 @@ class Node(object): ...@@ -42,6 +42,7 @@ class Node(object):
return self.state return self.state
def setState(self, new_state): def setState(self, new_state):
assert new_state in VALID_NODE_STATE_LIST
if self.state != new_state: if self.state != new_state:
self.state = new_state self.state = new_state
self.last_state_change = time() self.last_state_change = time()
......
...@@ -19,7 +19,7 @@ import logging ...@@ -19,7 +19,7 @@ import logging
from neo.protocol import UP_TO_DATE_STATE, OUT_OF_DATE_STATE, FEEDING_STATE, \ from neo.protocol import UP_TO_DATE_STATE, OUT_OF_DATE_STATE, FEEDING_STATE, \
DISCARDED_STATE, RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \ DISCARDED_STATE, RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \
BROKEN_STATE BROKEN_STATE, VALID_CELL_STATE_LIST
from neo.util import dump from neo.util import dump
class Cell(object): class Cell(object):
...@@ -27,12 +27,14 @@ class Cell(object): ...@@ -27,12 +27,14 @@ class Cell(object):
def __init__(self, node, state = UP_TO_DATE_STATE): def __init__(self, node, state = UP_TO_DATE_STATE):
self.node = node self.node = node
assert state in VALID_CELL_STATE_LIST
self.state = state self.state = state
def getState(self): def getState(self):
return self.state return self.state
def setState(self, state): def setState(self, state):
assert state in VALID_CELL_STATE_LIST
self.state = state self.state = state
def getNode(self): def getNode(self):
...@@ -112,6 +114,7 @@ class PartitionTable(object): ...@@ -112,6 +114,7 @@ class PartitionTable(object):
self.num_filled_rows = self.np self.num_filled_rows = self.np
def setCell(self, offset, node, state): def setCell(self, offset, node, state):
assert state in VALID_CELL_STATE_LIST
if state == DISCARDED_STATE: if state == DISCARDED_STATE:
return self.removeCell(offset, node) return self.removeCell(offset, node)
if node.getState() in (BROKEN_STATE, DOWN_STATE): if node.getState() in (BROKEN_STATE, DOWN_STATE):
......
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