Merge lp:~marcoceppi/charms/precise/mysql/32bit-fix into lp:charms/mysql

Proposed by Marco Ceppi
Status: Merged
Merged at revision: 88
Proposed branch: lp:~marcoceppi/charms/precise/mysql/32bit-fix
Merge into: lp:charms/mysql
Diff against target: 26 lines (+9/-0)
1 file modified
hooks/config-changed (+9/-0)
To merge this branch: bzr merge lp:~marcoceppi/charms/precise/mysql/32bit-fix
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+132979@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Note that I added a check for OverflowError upon merging, because you can't compare an int to a long without raising that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2012-09-13 22:49:49 +0000
+++ hooks/config-changed 2012-11-05 21:41:18 +0000
@@ -14,6 +14,11 @@
14# Going for the biggest page size to avoid wasted bytes. InnoDB page size is14# Going for the biggest page size to avoid wasted bytes. InnoDB page size is
15# 16MB15# 16MB
16PAGE_SIZE = 16*1024*102416PAGE_SIZE = 16*1024*1024
1732BIT_SYSTEM = sys.maxsize < 2**32
1832BIT_MEM_LIMIT = human_to_bytes('4G')
19
20if 32BIT_SYSTEM:
21 check_call(['juju-log','-l','INFO','32bit system restrictions in play'])
1722
18configs=json.loads(check_output(['config-get','--format=json']))23configs=json.loads(check_output(['config-get','--format=json']))
1924
@@ -37,6 +42,10 @@
37 return int(human[:-1]) * factors[modifier]42 return int(human[:-1]) * factors[modifier]
38 if modifier == '%':43 if modifier == '%':
39 total_ram = human_to_bytes(get_memtotal())44 total_ram = human_to_bytes(get_memtotal())
45
46 if 32BIT_SYSTEM and total_ram > 32BIT_MEM_LIMIT:
47 total_ram = 32BIT_MEM_LIMIT
48
40 factor = int(human[:-1]) * 0.0149 factor = int(human[:-1]) * 0.01
41 pctram = total_ram * factor50 pctram = total_ram * factor
42 return int(pctram - (pctram % PAGE_SIZE))51 return int(pctram - (pctram % PAGE_SIZE))

Subscribers

People subscribed via source and target branches

to all changes: