Skip to content

Commit

Permalink
Check snapCount
Browse files Browse the repository at this point in the history
  • Loading branch information
andreisavu committed Jul 16, 2010
1 parent 0d52ec5 commit a5d22dd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test.py
Expand Up @@ -156,6 +156,11 @@ def test_preAllocSize(self):
self.check('PreAllocSize', 0, 1, preAllocSize=-1)
self.check('PreAllocSize', 0, 0, preAllocSize=1024)

def test_snapCount(self):
self.check('SnapCount', 0, 1, snapCount=-1)
self.check('SnapCount', 1, 0, snapCount=100)
self.check('SnapCount', 0, 0, snapCount=10000)

def test_ElectionAlg(self):
self.check('ElectionAlg', 0, 1, electionAlg=5)
self.check('ElectionAlg', 1, 0, electionAlg=1)
Expand Down
21 changes: 20 additions & 1 deletion zoocfg.py
Expand Up @@ -201,6 +201,7 @@ def check(cls, cfg):
return warnings, errors

class PreAllocSize(BaseRule):
""" Transaction log block prealloc size """

@classmethod
def check(cls, cfg):
Expand All @@ -210,7 +211,25 @@ def check(cls, cfg):
errors.append('No `preAllocSize` found in config file.')

elif not isinstance(cfg.preAllocSize, int) or cfg.preAllocSize < 0:
errors.append('`preAllocSize` should be a positive number of kilobytes')
errors.append('`preAllocSize` should be a positive number of kilobytes.')

return warnings, errors

class SnapCount(BaseRule):
""" The number of transaction processed before a snapshot is generated """

@classmethod
def check(cls, cfg):
warnings, errors = [], []

if 'snapCount' not in cfg:
errors.append('No `snapCount` found in config file.')

elif not isinstance(cfg.snapCount, int) or cfg.snapCount < 0:
errors.append('`snapCount` should be a positive integer.')

elif cfg.snapCount < 5000:
warnings.append('Settings `snapCount` to low may hurt server performance.')

return warnings, errors

Expand Down

0 comments on commit a5d22dd

Please sign in to comment.