Commit 7ca55964 authored by Roque's avatar Roque

ERP5Type.Core.Folder: bundle parameter configurable on folder migration and...

ERP5Type.Core.Folder: bundle parameter configurable on folder migration and higher migration priority
- to ensure the number of activities doesn't increase infinitely with large module contents and to prevent conflicts on the module itself
parent d72e5627
......@@ -795,14 +795,13 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr
return self._folder_handler == HBTREE_HANDLER
security.declareProtected( Permissions.ManagePortal, 'migrateToHBTree' )
def migrateToHBTree(self, migration_generate_id_method=None, new_generate_id_method='_generatePerDayId', REQUEST=None):
def migrateToHBTree(self, migration_generate_id_method=None, new_generate_id_method='_generatePerDayId', bundle_count=10, REQUEST=None):
"""
Function to migrate from a BTree folder to HBTree folder.
It will first call setId on all folder objects to have right id
to be used with an hbtreefolder.
Then it will migrate foder from btree to hbtree.
"""
BUNDLE_COUNT = 10
# if folder is already migrated or migration process is in progress
# do not do anything beside logging
......@@ -822,15 +821,15 @@ class Folder(FolderMixIn, CopyContainer, ObjectManager, Base, OFSFolder2, CMFBTr
tag = "%s/%s/migrate" %(self.getId(),migration_generate_id_method)
id_list = list(self.objectIds())
# set new id by bundle
for x in xrange(len(self) / BUNDLE_COUNT):
self.activate(activity="SQLQueue", tag=tag).ERP5Site_setNewIdPerBundle(
for x in xrange(len(self) / bundle_count):
self.activate(activity="SQLQueue", tag=tag, priority=3, serialization_tag='ERP5Site_setNewIdPerBundle').ERP5Site_setNewIdPerBundle(
self.getPath(),
id_list[x*BUNDLE_COUNT:(x+1)*BUNDLE_COUNT],
id_list[x*bundle_count:(x+1)*bundle_count],
migration_generate_id_method, tag)
remaining_id_count = len(self) % BUNDLE_COUNT
remaining_id_count = len(self) % bundle_count
if remaining_id_count:
self.activate(activity="SQLQueue", tag=tag).ERP5Site_setNewIdPerBundle(
self.activate(activity="SQLQueue", tag=tag, priority=3, serialization_tag='ERP5Site_setNewIdPerBundle').ERP5Site_setNewIdPerBundle(
self.getPath(),
id_list[-remaining_id_count:],
migration_generate_id_method, tag)
......
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