[Zodb-checkins] CVS: ZODB3/Tools - update.py:1.1.2.1
Jeremy Hylton
jeremy@zope.com
Tue, 17 Dec 2002 12:34:34 -0500
Update of /cvs-repository/ZODB3/Tools
In directory cvs.zope.org:/tmp/cvs-serv23225
Added Files:
Tag: ZODB3-fast-restart-branch
update.py
Log Message:
Update a bunch of objects.
=== Added File ZODB3/Tools/update.py ===
#! /usr/bin/env python2.1
import random
import ZODB
from ZEO.ClientStorage import ClientStorage
SERVER = "guido", 9000
MB = 1024**2
CACHE_SIZE = 200 * MB
CLIENT = "cache"
RECONNECT_TIMEOUT = 10
NEARLY_FULL = CACHE_SIZE * 0.45
def main():
cs = ClientStorage(SERVER, cache_size=CACHE_SIZE, client=CLIENT,
max_disconnect_poll=RECONNECT_TIMEOUT)
db = ZODB.DB(cs)
cn = db.open()
rt = cn.root()
objs = rt["objects"]
cache = cs._cache
num_objs = len(objs)
j = 0
while cache._pos < NEARLY_FULL:
print "cache size", cache._pos
i = random.randint(0, num_objs)
obj = objs[i]
size = 2 ** random.randint(1, 20)
obj.value = "u" * size
j += 1
if j % 20 == 0:
get_transaction().commit()
if __name__ == "__main__":
main()