diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 45d8ac2102..c01b6833fc 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -66,6 +66,9 @@ ${db.schema.update.lockRetryWaitSeconds} + + + classpath:alfresco/dbscripts/create/${db.script.dialect}/AlfrescoCreate-RepoTables.sql diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-Person.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-Person.sql index be5a6b9382..190c60f123 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-Person.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-Person.sql @@ -8,6 +8,7 @@ -- -- Path was previously unused and unindex - new we use it the index is required. +--FOREACH alf_child_assoc.id system.upgrade.alf_child_assoc.batchsize UPDATE alf_child_assoc SET @@ -45,6 +46,7 @@ UPDATE qq.local_name ='userName' AND nn.uri = 'http://www.alfresco.org/model/content/1.0' ) + AND alf_child_assoc.id >= ${LOWERBOUND} AND alf_child_assoc.id <= ${UPPERBOUND} ; -- Validation query diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-A--to--2.2-ACL.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-A--to--2.2-ACL.sql index 2acba53240..9820fb724f 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-A--to--2.2-ACL.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-A--to--2.2-ACL.sql @@ -29,8 +29,11 @@ ALTER TABLE alf_access_control_list ADD CONSTRAINT fk_alf_acl_acs FOREIGN KEY (acl_change_set) REFERENCES alf_acl_change_set (id), ADD INDEX idx_alf_acl_inh (inherits, inherits_from); +--FOREACH alf_access_control_list.id system.upgrade.alf_access_control_list.batchsize UPDATE alf_access_control_list acl - set acl_id = (acl.id); + set acl_id = (acl.id) + WHERE acl.id >= ${LOWERBOUND} AND acl.id <= ${UPPERBOUND}; + ALTER TABLE alf_access_control_list ADD UNIQUE (acl_id, latest, acl_version); @@ -85,8 +88,11 @@ ALTER TABLE alf_access_control_entry DROP INDEX FKFFF41F99B25A50BF, DROP FOREIGN -- migrate data - build equivalent ACL entries +--FOREACH alf_access_control_list.id system.upgrade.alf_acl_member.batchsize INSERT INTO alf_acl_member (version, acl_id, ace_id, pos) - select 1, ace.acl_id, ace.id, 0 from alf_access_control_entry ace join alf_access_control_list acl on acl.id = ace.acl_id; + select 1, ace.acl_id, ace.id, 0 + from alf_access_control_entry ace join alf_access_control_list acl on acl.id = ace.acl_id + where acl.id >= ${LOWERBOUND} AND acl.id <= ${UPPERBOUND}; -- Create ACE context CREATE TABLE alf_ace_context ( @@ -141,6 +147,7 @@ CREATE TABLE alf_tmp_min_ace ( UNIQUE (permission_id, authority_id, allowed, applies) ) ENGINE=InnoDB; +--FOREACH alf_access_control_entry.authority_id system.upgrade.alf_tmp_min_ace.batchsize INSERT INTO alf_tmp_min_ace (min, permission_id, authority_id, allowed, applies) SELECT min(ace1.id), @@ -150,21 +157,24 @@ INSERT INTO alf_tmp_min_ace (min, permission_id, authority_id, allowed, applies) ace1.applies FROM alf_access_control_entry ace1 + WHERE + ace1.authority_id >= ${LOWERBOUND} AND ace1.authority_id <= ${UPPERBOUND} GROUP BY ace1.permission_id, ace1.authority_id, ace1.allowed, ace1.applies ; -- Update members to point to the first use of an access control entry +--FOREACH alf_acl_member.id system.upgrade.alf_acl_member.batchsize UPDATE alf_acl_member mem SET ace_id = (SELECT help.min FROM alf_access_control_entry ace JOIN alf_tmp_min_ace help ON help.permission_id = ace.permission_id AND - help.authority_id = ace.authority_id AND - help.allowed = ace.allowed AND - help.applies = ace.applies - WHERE ace.id = mem.ace_id ); - + help.authority_id = ace.authority_id AND + help.allowed = ace.allowed AND + help.applies = ace.applies + WHERE ace.id = mem.ace_id ) + WHERE mem.id >= ${LOWERBOUND} AND mem.id <= ${UPPERBOUND}; DROP TABLE alf_tmp_min_ace; -- Remove duplicate aces the mysql way (as you can not use the deleted table in the where clause ...) diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-ACL.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-ACL.sql index 5f630158d0..2662d5c422 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-ACL.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-ACL.sql @@ -29,8 +29,11 @@ ALTER TABLE alf_access_control_list ADD CONSTRAINT fk_alf_acl_acs FOREIGN KEY (acl_change_set) REFERENCES alf_acl_change_set (id), ADD INDEX idx_alf_acl_inh (inherits, inherits_from); +--FOREACH alf_access_control_list.id system.upgrade.alf_access_control_list.batchsize UPDATE alf_access_control_list acl - set acl_id = (acl.id); + set acl_id = (acl.id) + WHERE acl.id >= ${LOWERBOUND} AND acl.id <= ${UPPERBOUND}; + ALTER TABLE alf_access_control_list ADD UNIQUE (acl_id, latest, acl_version); @@ -75,13 +78,18 @@ ALTER TABLE alf_authority ADD UNIQUE (authority, crc); -- migrate data - fix up FK refs to authority +--FOREACH alf_access_control_entry.id system.upgrade.alf_access_control_entry.batchsize UPDATE alf_access_control_entry ace - set auth_id = (select id from alf_authority a where a.authority = ace.authority_id); + set auth_id = (select id from alf_authority a where a.authority = ace.authority_id) + WHERE ace.id >= ${LOWERBOUND} AND ace.id <= ${UPPERBOUND}; -- migrate data - build equivalent ACL entries +--FOREACH alf_access_control_list.id system.upgrade.alf_acl_member.batchsize INSERT INTO alf_acl_member (version, acl_id, ace_id, pos) - select 1, ace.acl_id, ace.id, 0 from alf_access_control_entry ace join alf_access_control_list acl on acl.id = ace.acl_id; + select 1, ace.acl_id, ace.id, 0 + from alf_access_control_entry ace join alf_access_control_list acl on acl.id = ace.acl_id + where acl.id >= ${LOWERBOUND} AND acl.id <= ${UPPERBOUND}; -- Create ACE context CREATE TABLE alf_ace_context ( @@ -134,6 +142,7 @@ CREATE TABLE alf_tmp_min_ace ( UNIQUE (permission_id, authority_id, allowed, applies) ) ENGINE=InnoDB; +--FOREACH alf_access_control_entry.authority_id system.upgrade.alf_tmp_min_ace.batchsize INSERT INTO alf_tmp_min_ace (min, permission_id, authority_id, allowed, applies) SELECT min(ace1.id), @@ -143,12 +152,15 @@ INSERT INTO alf_tmp_min_ace (min, permission_id, authority_id, allowed, applies) ace1.applies FROM alf_access_control_entry ace1 + WHERE + ace1.authority_id >= ${LOWERBOUND} AND ace1.authority_id <= ${UPPERBOUND} GROUP BY ace1.permission_id, ace1.authority_id, ace1.allowed, ace1.applies ; -- Update members to point to the first use of an access control entry +--FOREACH alf_acl_member.id system.upgrade.alf_acl_member.batchsize UPDATE alf_acl_member mem SET ace_id = (SELECT help.min FROM alf_access_control_entry ace JOIN alf_tmp_min_ace help @@ -156,8 +168,8 @@ UPDATE alf_acl_member mem help.authority_id = ace.authority_id AND help.allowed = ace.allowed AND help.applies = ace.applies - WHERE ace.id = mem.ace_id ); - + WHERE ace.id = mem.ace_id ) + WHERE mem.id >= ${LOWERBOUND} AND mem.id <= ${UPPERBOUND}; DROP TABLE alf_tmp_min_ace; -- Remove duplicate aces the mysql way (as you can not use the deleted table in the where clause ...) diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-CleanNodeStatuses.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-CleanNodeStatuses.sql index 3fca009a94..8040433bba 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-CleanNodeStatuses.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.2-CleanNodeStatuses.sql @@ -15,35 +15,53 @@ CREATE TABLE t_node_status transaction_id BIGINT(20) NOT NULL, PRIMARY KEY (node_id) ); +--FOREACH alf_node_status.node_id system.upgrade.t_node_status.batchsize INSERT INTO t_node_status ( SELECT c.node_id, c.transaction_id FROM ( - SELECT COUNT(node_id) x, ns.node_id, ns.transaction_id FROM alf_node_status ns GROUP BY node_id + SELECT COUNT(node_id) x, ns.node_id, ns.transaction_id FROM alf_node_status ns + WHERE node_id >= ${LOWERBOUND} AND node_id <= ${UPPERBOUND} + GROUP BY node_id ) c WHERE c.x > 1 ); -DELETE FROM alf_node_status WHERE node_id IN (SELECT node_id FROM t_node_status); +--FOREACH alf_node_status.node_id system.upgrade.alf_node_status.batchsize +DELETE FROM alf_node_status +WHERE node_id IN (SELECT node_id FROM t_node_status) +AND node_id >= ${LOWERBOUND} AND node_id <= ${UPPERBOUND}; + +--FOREACH t_node_status.node_id system.upgrade.alf_node_status.batchsize INSERT INTO alf_node_status (protocol, identifier, guid, node_id, transaction_id, version) ( - SELECT n.protocol, n.identifier, n.uuid, n.id, tns.transaction_id, 0 FROM t_node_status tns JOIN alf_node n ON (n.id = tns.node_id) + SELECT n.protocol, n.identifier, n.uuid, n.id, tns.transaction_id, 0 + FROM t_node_status tns JOIN alf_node n ON (n.id = tns.node_id) + WHERE tns.node_id >= ${LOWERBOUND} AND tns.node_id <= ${UPPERBOUND} ); DROP TABLE t_node_status; -DELETE FROM alf_node_status WHERE node_id IS NULL; +--FOREACH alf_node_status.node_id system.upgrade.alf_node_status.batchsize +DELETE FROM alf_node_status +WHERE node_id IS NULL +AND node_id >= ${LOWERBOUND} AND node_id <= ${UPPERBOUND}; +--FOREACH alf_node_status.node_id system.upgrade.alf_node_status.batchsize UPDATE alf_node_status ns SET ns.protocol = ( - SELECT n.protocol FROM alf_node n WHERE n.id = ns.node_id - ); + SELECT n.protocol FROM alf_node n + WHERE n.id = ns.node_id + ) +WHERE ns.node_id >= ${LOWERBOUND} AND ns.node_id <= ${UPPERBOUND}; +--FOREACH alf_transaction.id system.upgrade.alf_transaction.batchsize DELETE alf_transaction FROM alf_transaction LEFT JOIN alf_node_status ON (alf_node_status.transaction_id = alf_transaction.id) WHERE - alf_node_status.node_id is null; + alf_node_status.node_id is null + AND alf_transaction.id >= ${LOWERBOUND} AND alf_transaction.id <= ${UPPERBOUND}; -- -- Record script finish diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql index d3500a2480..cb736f7498 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql @@ -282,14 +282,7 @@ INSERT INTO t_summary_nstat (node_id, transaction_id) SELECT node_id, transaction_id FROM alf_node_status WHERE node_id IS NOT NULL; -- Copy data over ---BEGIN TXN -LOCK TABLES - t_alf_node WRITE, - alf_node AS n READ, - t_summary_nstat AS nstat READ, - t_alf_store AS s READ, - t_qnames AS q READ -; +--FOREACH alf_node.id system.upgrade.t_alf_node.batchsize INSERT INTO t_alf_node ( id, version, store_id, uuid, transaction_id, node_deleted, type_qname_id, acl_id, @@ -303,9 +296,9 @@ INSERT INTO t_alf_node JOIN t_qnames q ON (q.qname = n.type_qname) JOIN t_summary_nstat nstat ON (nstat.node_id = n.id) JOIN t_alf_store s ON (s.protocol = n.protocol AND s.identifier = n.identifier) + WHERE + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; DROP TABLE t_summary_nstat; -- Hook the store up to the root node @@ -373,13 +366,7 @@ CREATE TABLE t_alf_child_assoc UNIQUE (parent_node_id, type_qname_id, child_node_name_crc, child_node_name) ) TYPE=InnoDB; ---BEGIN TXN -LOCK TABLES - t_alf_child_assoc WRITE, - alf_child_assoc AS ca READ, - t_qnames_dyn AS tqndyn READ, - t_qnames AS tqn READ -; +--FOREACH alf_child_assoc.id system.upgrade.t_alf_child_assoc.batchsize INSERT INTO t_alf_child_assoc ( id, version, @@ -402,9 +389,9 @@ INSERT INTO t_alf_child_assoc alf_child_assoc ca JOIN t_qnames_dyn tqndyn ON (ca.qname = tqndyn.qname) JOIN t_qnames tqn ON (ca.type_qname = tqn.qname) + WHERE + ca.id >= ${LOWERBOUND} AND ca.id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Clean up DROP TABLE t_qnames_dyn; @@ -432,12 +419,7 @@ CREATE TABLE t_alf_node_assoc UNIQUE (source_node_id, target_node_id, type_qname_id) ) TYPE=InnoDB; ---BEGIN TXN -LOCK TABLES - t_alf_node_assoc WRITE, - alf_node_assoc AS na READ, - t_qnames AS tqn READ -; +--FOREACH alf_node_assoc.id system.upgrade.t_alf_node_assoc.batchsize INSERT INTO t_alf_node_assoc ( id, version, @@ -451,9 +433,9 @@ INSERT INTO t_alf_node_assoc FROM alf_node_assoc na JOIN t_qnames tqn ON (na.type_qname = tqn.qname) + WHERE + na.id >= ${LOWERBOUND} AND na.id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Clean up DROP TABLE alf_node_assoc; @@ -507,12 +489,7 @@ CREATE TABLE t_alf_node_aspects PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; ---BEGIN TXN -LOCK TABLES - t_alf_node_aspects WRITE, - alf_node_aspects AS na READ, - t_qnames AS tqn READ -; +--FOREACH alf_node_aspects.node_id system.upgrade.t_alf_node_aspects.batchsize -- Note the omission of sys:referencable. This is implicit. INSERT INTO t_alf_node_aspects ( @@ -526,9 +503,8 @@ INSERT INTO t_alf_node_aspects JOIN t_qnames tqn ON (na.qname = tqn.qname) WHERE tqn.qname != '{http://www.alfresco.org/model/system/1.0}referenceable' + AND na.node_id >= ${LOWERBOUND} AND na.node_id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Clean up DROP TABLE alf_node_aspects; @@ -549,6 +525,7 @@ CREATE TABLE t_avm_aspects PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; +--FOREACH avm_aspects.node_id system.upgrade.t_avm_aspects.batchsize INSERT INTO t_avm_aspects ( node_id, qname_id @@ -559,7 +536,10 @@ INSERT INTO t_avm_aspects FROM avm_aspects aspects_old JOIN t_qnames tqn ON (aspects_old.qname = tqn.qname) + WHERE + aspects_old.node_id >= ${LOWERBOUND} AND aspects_old.node_id <= ${UPPERBOUND} ; +--FOREACH avm_aspects_new.id system.upgrade.t_avm_aspects.batchsize INSERT INTO t_avm_aspects ( node_id, qname_id @@ -573,6 +553,7 @@ INSERT INTO t_avm_aspects LEFT JOIN avm_aspects aold ON (anew.id = aold.node_id AND anew.name = aold.qname) WHERE aold.id IS NULL + AND anew.id >= ${LOWERBOUND} AND anew.id <= ${UPPERBOUND} ; -- Clean up @@ -632,6 +613,7 @@ CREATE TABLE t_avm_store_properties CONSTRAINT fk_avm_sprop_qname FOREIGN KEY (qname_id) REFERENCES alf_qname (id), PRIMARY KEY (id) ) TYPE=InnoDB; +--FOREACH avm_store_properties.avm_store_id system.upgrade.t_avm_store_properties.batchsize INSERT INTO t_avm_store_properties ( avm_store_id, @@ -649,6 +631,8 @@ INSERT INTO t_avm_store_properties JOIN t_qnames tqn ON (p.qname = tqn.qname) JOIN t_prop_types ptypes_actual ON (ptypes_actual.type_name = p.actual_type) JOIN t_prop_types ptypes_persisted ON (ptypes_persisted.type_name = p.persisted_type) + WHERE + p.avm_store_id >= ${LOWERBOUND} AND p.avm_store_id <= ${UPPERBOUND} ; DROP TABLE avm_store_properties; ALTER TABLE t_avm_store_properties RENAME TO avm_store_properties; @@ -673,6 +657,7 @@ CREATE TABLE t_avm_node_properties CONSTRAINT fk_avm_nprop_qn FOREIGN KEY (qname_id) REFERENCES alf_qname (id), PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; +--FOREACH avm_node_properties_new.node_id system.upgrade.t_avm_node_properties.batchsize INSERT INTO t_avm_node_properties ( node_id, @@ -690,7 +675,10 @@ INSERT INTO t_avm_node_properties JOIN t_qnames tqn ON (p.qname = tqn.qname) JOIN t_prop_types ptypes_actual ON (ptypes_actual.type_name = p.actual_type) JOIN t_prop_types ptypes_persisted ON (ptypes_persisted.type_name = p.persisted_type) + WHERE + p.node_id >= ${LOWERBOUND} AND p.node_id <= ${UPPERBOUND} ; +--FOREACH avm_node_properties.node_id system.upgrade.t_avm_node_properties.batchsize INSERT INTO t_avm_node_properties ( node_id, @@ -711,6 +699,7 @@ INSERT INTO t_avm_node_properties LEFT OUTER JOIN t_avm_node_properties tanp ON (tqn.qname_id = tanp.qname_id) WHERE tanp.qname_id IS NULL + AND p.node_id >= ${LOWERBOUND} AND p.node_id <= ${UPPERBOUND} ; DROP TABLE avm_node_properties_new; @@ -771,13 +760,7 @@ CREATE TABLE t_alf_node_properties --BEGIN TXN -- Copy values over -LOCK TABLES - t_alf_node_properties WRITE, - alf_node_properties AS np READ, - t_prop_types AS ptypes_actual READ, - t_prop_types AS ptypes_persisted READ, - t_qnames AS tqn READ -; +--FOREACH alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize INSERT INTO t_alf_node_properties ( node_id, qname_id, locale_id, list_index, @@ -799,11 +782,11 @@ INSERT INTO t_alf_node_properties JOIN t_prop_types ptypes_persisted ON (ptypes_persisted.type_name = np.persisted_type) WHERE np.attribute_value IS NULL + AND np.node_id >= ${LOWERBOUND} AND np.node_id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Update cm:auditable properties on the nodes +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_creator = ( SELECT @@ -815,8 +798,10 @@ UPDATE t_alf_node n SET audit_creator = WHERE np.node_id = n.id AND ns.uri = 'FILLER-http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'creator' + qn.local_name = 'creator' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_created = ( SELECT @@ -828,8 +813,10 @@ UPDATE t_alf_node n SET audit_created = WHERE np.node_id = n.id AND ns.uri = 'FILLER-http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'created' + qn.local_name = 'created' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_modifier = ( SELECT @@ -841,8 +828,10 @@ UPDATE t_alf_node n SET audit_modifier = WHERE np.node_id = n.id AND ns.uri = 'FILLER-http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'modifier' + qn.local_name = 'modifier' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_modified = ( SELECT @@ -854,7 +843,8 @@ UPDATE t_alf_node n SET audit_modified = WHERE np.node_id = n.id AND ns.uri = 'FILLER-http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'modified' + qn.local_name = 'modified' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); -- Remove the unused cm:auditable properties -- SHORTCUT: @@ -870,16 +860,19 @@ UPDATE t_alf_node n SET audit_modified = -- FROM t_alf_node_properties -- WHERE -- qname_id IN (13, 14, 23, 24); +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize DELETE t_alf_node_properties FROM t_alf_node_properties JOIN alf_qname ON (t_alf_node_properties.qname_id = alf_qname.id) JOIN alf_namespace ON (alf_qname.ns_id = alf_namespace.id) WHERE alf_namespace.uri = 'FILLER-http://www.alfresco.org/model/content/1.0' AND - alf_qname.local_name IN ('creator', 'created', 'modifier', 'modified') + alf_qname.local_name IN ('creator', 'created', 'modifier', 'modified') AND + t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} ; -- Copy all MLText values over +--FOREACH alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize INSERT INTO t_alf_node_properties ( node_id, qname_id, locale_id, list_index, @@ -901,16 +894,26 @@ INSERT INTO t_alf_node_properties JOIN alf_map_attribute_entries ma ON (ma.map_id = a1.id) JOIN alf_locale loc ON (ma.mkey = loc.locale_str) JOIN alf_attributes a2 ON (ma.attribute_id = a2.id) + WHERE + np.node_id >= ${LOWERBOUND} AND np.node_id <= ${UPPERBOUND} ; -- (OPTIONAL) +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize UPDATE t_alf_node_properties SET actual_type_n = 6, persisted_type_n = 6, serializable_value = NULL WHERE actual_type_n = -1 AND string_value IS NOT NULL + AND t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} ; +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize UPDATE t_alf_node_properties SET actual_type_n = 9, persisted_type_n = 9 WHERE actual_type_n = -1 AND serializable_value IS NOT NULL + AND t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} +; +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize +DELETE FROM t_alf_node_properties + WHERE actual_type_n = -1 + AND t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} ; -DELETE FROM t_alf_node_properties WHERE actual_type_n = -1; -- Delete the node properties and move the fixed values over DROP TABLE alf_node_properties; diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql index 5f02e50b1e..c983a33ebd 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql @@ -73,14 +73,8 @@ CREATE TABLE t_summary_nstat INSERT INTO t_summary_nstat (node_id, transaction_id) SELECT node_id, transaction_id FROM alf_node_status WHERE node_id IS NOT NULL; ---BEGIN TXN -- Copy data over -LOCK TABLES - t_alf_node WRITE, - alf_node AS n READ, - t_summary_nstat AS nstat READ, - t_alf_store AS s READ -; +--FOREACH alf_node.id system.upgrade.t_alf_node.batchsize INSERT INTO t_alf_node ( id, version, store_id, uuid, transaction_id, node_deleted, type_qname_id, acl_id, @@ -93,9 +87,9 @@ INSERT INTO t_alf_node alf_node n JOIN t_summary_nstat nstat ON (nstat.node_id = n.id) JOIN t_alf_store s ON (s.protocol = n.protocol AND s.identifier = n.identifier) + WHERE + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; DROP TABLE t_summary_nstat; -- Hook the store up to the root node @@ -163,11 +157,7 @@ CREATE TABLE t_alf_child_assoc UNIQUE (parent_node_id, type_qname_id, child_node_name_crc, child_node_name) ) TYPE=InnoDB; ---BEGIN TXN -LOCK TABLES - t_alf_child_assoc WRITE, - alf_child_assoc AS ca READ -; +--FOREACH alf_child_assoc.id system.upgrade.t_alf_child_assoc.batchsize INSERT INTO t_alf_child_assoc ( id, version, @@ -188,9 +178,9 @@ INSERT INTO t_alf_child_assoc ca.is_primary, ca.assoc_index FROM alf_child_assoc ca + WHERE + ca.id >= ${LOWERBOUND} AND ca.id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Clean up DROP TABLE alf_child_assoc; @@ -217,11 +207,7 @@ CREATE TABLE t_alf_node_assoc UNIQUE (source_node_id, target_node_id, type_qname_id) ) TYPE=InnoDB; ---BEGIN TXN -LOCK TABLES - t_alf_node_assoc WRITE, - alf_node_assoc AS na READ -; +--FOREACH alf_node_assoc.id system.upgrade.t_alf_node_assoc.batchsize INSERT INTO t_alf_node_assoc ( id, version, @@ -234,9 +220,9 @@ INSERT INTO t_alf_node_assoc na.type_qname_id FROM alf_node_assoc na + WHERE + na.id >= ${LOWERBOUND} AND na.id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Clean up DROP TABLE alf_node_assoc; @@ -290,13 +276,7 @@ CREATE TABLE t_alf_node_aspects PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; ---BEGIN TXN -LOCK TABLES - t_alf_node_aspects WRITE, - alf_node_aspects AS na READ, - alf_qname AS qn READ, - alf_namespace AS ns READ -; +--FOREACH alf_node_aspects.node_id system.upgrade.t_alf_node_aspects.batchsize -- Note the omission of sys:referencable. This is implicit. INSERT INTO t_alf_node_aspects ( @@ -312,9 +292,8 @@ INSERT INTO t_alf_node_aspects WHERE ns.uri != 'http://www.alfresco.org/model/system/1.0' OR qn.local_name != 'referenceable' + AND na.node_id >= ${LOWERBOUND} AND na.node_id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Clean up DROP TABLE alf_node_aspects; @@ -335,6 +314,7 @@ CREATE TABLE t_avm_aspects PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; +--FOREACH avm_aspects_new.id system.upgrade.t_avm_aspects.batchsize INSERT INTO t_avm_aspects ( node_id, qname_id @@ -344,6 +324,8 @@ INSERT INTO t_avm_aspects anew.qname_id FROM avm_aspects_new anew + WHERE + anew.id >= ${LOWERBOUND} AND anew.id <= ${UPPERBOUND} ; -- Clean up @@ -376,6 +358,7 @@ CREATE TABLE t_avm_store_properties CONSTRAINT fk_avm_sprop_qname FOREIGN KEY (qname_id) REFERENCES alf_qname (id), PRIMARY KEY (id) ) TYPE=InnoDB; +--FOREACH avm_store_properties.avm_store_id system.upgrade.t_avm_store_properties.batchsize INSERT INTO t_avm_store_properties ( avm_store_id, @@ -390,6 +373,8 @@ INSERT INTO t_avm_store_properties p.multi_valued, p.boolean_value, p.long_value, p.float_value, p.double_value, p.string_value, p.serializable_value FROM avm_store_properties p + WHERE + p.avm_store_id >= ${LOWERBOUND} AND p.avm_store_id <= ${UPPERBOUND} ; DROP TABLE avm_store_properties; ALTER TABLE t_avm_store_properties RENAME TO avm_store_properties; @@ -414,6 +399,7 @@ CREATE TABLE t_avm_node_properties CONSTRAINT fk_avm_nprop_qn FOREIGN KEY (qname_id) REFERENCES alf_qname (id), PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; +--FOREACH avm_node_properties_new.node_id system.upgrade.t_avm_node_properties.batchsize INSERT INTO t_avm_node_properties ( node_id, @@ -428,6 +414,8 @@ INSERT INTO t_avm_node_properties p.multi_valued, p.boolean_value, p.long_value, p.float_value, p.double_value, p.string_value, p.serializable_value FROM avm_node_properties_new p + WHERE + p.node_id >= ${LOWERBOUND} AND p.node_id <= ${UPPERBOUND} ; DROP TABLE avm_node_properties_new; @@ -487,10 +475,7 @@ CREATE TABLE t_alf_node_properties --BEGIN TXN -- Copy values over -LOCK TABLES - t_alf_node_properties WRITE, - alf_node_properties AS np READ -; +--FOREACH alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize INSERT INTO t_alf_node_properties ( node_id, qname_id, locale_id, list_index, @@ -509,11 +494,11 @@ INSERT INTO t_alf_node_properties alf_node_properties np WHERE np.attribute_value IS NULL + AND np.node_id >= ${LOWERBOUND} AND np.node_id <= ${UPPERBOUND} ; ---END TXN -UNLOCK TABLES; -- Update cm:auditable properties on the nodes +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_creator = ( SELECT @@ -525,8 +510,10 @@ UPDATE t_alf_node n SET audit_creator = WHERE np.node_id = n.id AND ns.uri = 'http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'creator' + qn.local_name = 'creator' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_created = ( SELECT @@ -538,8 +525,10 @@ UPDATE t_alf_node n SET audit_created = WHERE np.node_id = n.id AND ns.uri = 'http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'created' + qn.local_name = 'created' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_modifier = ( SELECT @@ -551,8 +540,10 @@ UPDATE t_alf_node n SET audit_modifier = WHERE np.node_id = n.id AND ns.uri = 'http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'modifier' + qn.local_name = 'modifier' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); +--FOREACH t_alf_node.id system.upgrade.t_alf_node.batchsize UPDATE t_alf_node n SET audit_modified = ( SELECT @@ -564,19 +555,23 @@ UPDATE t_alf_node n SET audit_modified = WHERE np.node_id = n.id AND ns.uri = 'http://www.alfresco.org/model/content/1.0' AND - qn.local_name = 'modified' + qn.local_name = 'modified' AND + n.id >= ${LOWERBOUND} AND n.id <= ${UPPERBOUND} ); -- Remove the unused cm:auditable properties +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize DELETE t_alf_node_properties FROM t_alf_node_properties JOIN alf_qname ON (t_alf_node_properties.qname_id = alf_qname.id) JOIN alf_namespace ON (alf_qname.ns_id = alf_namespace.id) WHERE alf_namespace.uri = 'http://www.alfresco.org/model/content/1.0' AND - alf_qname.local_name IN ('creator', 'created', 'modifier', 'modified') + alf_qname.local_name IN ('creator', 'created', 'modifier', 'modified') AND + t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} ; -- Copy all MLText values over +--FOREACH alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize INSERT INTO t_alf_node_properties ( node_id, qname_id, list_index, locale_id, @@ -597,16 +592,26 @@ INSERT INTO t_alf_node_properties JOIN alf_map_attribute_entries ma ON (ma.map_id = a1.id) JOIN alf_locale loc ON (ma.mkey = loc.locale_str) JOIN alf_attributes a2 ON (ma.attribute_id = a2.id) + WHERE + np.node_id >= ${LOWERBOUND} AND np.node_id <= ${UPPERBOUND} ; -- (OPTIONAL) +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize UPDATE t_alf_node_properties SET actual_type_n = 6, persisted_type_n = 6, serializable_value = NULL WHERE actual_type_n = -1 AND string_value IS NOT NULL + AND t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} ; +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize UPDATE t_alf_node_properties SET actual_type_n = 9, persisted_type_n = 9 WHERE actual_type_n = -1 AND serializable_value IS NOT NULL + AND t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} +; +--FOREACH t_alf_node_properties.node_id system.upgrade.t_alf_node_properties.batchsize +DELETE FROM t_alf_node_properties + WHERE actual_type_n = -1 + AND t_alf_node_properties.node_id >= ${LOWERBOUND} AND t_alf_node_properties.node_id <= ${UPPERBOUND} ; -DELETE FROM t_alf_node_properties WHERE actual_type_n = -1; -- Delete the node properties and move the fixed values over DROP TABLE alf_node_properties; diff --git a/config/alfresco/messages/avm-messages.properties b/config/alfresco/messages/avm-messages.properties index 311f9966c5..793ac11fa6 100644 --- a/config/alfresco/messages/avm-messages.properties +++ b/config/alfresco/messages/avm-messages.properties @@ -2,4 +2,7 @@ expiredcontent.workflow.title=Expired Content In ''{0}'' avmlockservice.locked=You do not have access to ''{0}''; it is currently locked by user ''{1}''. -testserver.taken=The test server ''{0}'' you selected has been allocated to another user, if possible, select a different server and try again. \ No newline at end of file +testserver.taken=The test server ''{0}'' you selected has been allocated to another user, if possible, select a different server and try again. + +avm.cycle.create=Cycle would be created. +avm.cycle.lookup=Cycle in lookup. \ No newline at end of file diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index a189ab741a..7f65ec3ad0 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -20,6 +20,11 @@ dir.indexes.backup=${dir.root}/backup-lucene-indexes # The location for lucene index locks dir.indexes.lock=${dir.indexes}/locks +# Is the JBPM Deploy Process Servlet enabled? +# Default is false. Should not be enabled in production environments as the +# servlet allows unauthenticated deployment of new workflows. +system.workflow.deployservlet.enabled=false + # ######################################### # # Index Recovery and Tracking Configuration # # ######################################### # diff --git a/config/alfresco/subsystems/imap/default/imap-server-context.xml b/config/alfresco/subsystems/imap/default/imap-server-context.xml index 925af0169d..bed350a7d2 100644 --- a/config/alfresco/subsystems/imap/default/imap-server-context.xml +++ b/config/alfresco/subsystems/imap/default/imap-server-context.xml @@ -13,8 +13,8 @@ - - + + ${imap.server.host} ${imap.server.port} diff --git a/config/alfresco/subsystems/imap/default/imap-server.properties b/config/alfresco/subsystems/imap/default/imap-server.properties index 13ede9fd25..681138f48b 100644 --- a/config/alfresco/subsystems/imap/default/imap-server.properties +++ b/config/alfresco/subsystems/imap/default/imap-server.properties @@ -1,5 +1,6 @@ imap.server.enabled=false imap.server.port=143 +imap.server.host=0.0.0.0 imap.mail.from.default=alfresco@demo.alfresco.org diff --git a/source/java/org/alfresco/repo/avm/AVMFileFolderPerformanceTester.java b/source/java/org/alfresco/repo/avm/AVMFileFolderPerformanceTester.java new file mode 100644 index 0000000000..603900678a --- /dev/null +++ b/source/java/org/alfresco/repo/avm/AVMFileFolderPerformanceTester.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.avm; + +import org.alfresco.repo.model.filefolder.FileFolderPerformanceTester; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; + +/** + * @see FileFolderPerformanceTester + */ +public class AVMFileFolderPerformanceTester extends FileFolderPerformanceTester +{ + @Override + protected NodeService getNodeService() + { + // note: vanilla AVM stores are defined as indexed by default, hence + // use "avmLockingAwareNodeService" for now (which, unlike "avmNodeService", is also indexing aware) + // so that index is created when store is created (else config check will fail on restart) + return (NodeService)ctx.getBean("avmLockingAwareNodeService"); + } + + protected NodeRef getOrCreateRootFolder() + { + RetryingTransactionCallback callback = new RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + String storeName = "AVMFileFolderPerformanceTester-"+System.currentTimeMillis(); + StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_AVM, storeName); + return nodeService.getRootNode(storeRef); + } + }; + return retryingTransactionHelper.doInTransaction(callback); + } +} diff --git a/source/java/org/alfresco/repo/avm/AVMNodeService.java b/source/java/org/alfresco/repo/avm/AVMNodeService.java index 43b211e2d8..f24dca98dc 100644 --- a/source/java/org/alfresco/repo/avm/AVMNodeService.java +++ b/source/java/org/alfresco/repo/avm/AVMNodeService.java @@ -18,6 +18,8 @@ package org.alfresco.repo.avm; +import java.io.IOException; +import java.io.OutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -394,7 +396,15 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi else if (nodeTypeQName.equals(WCMModel.TYPE_AVM_PLAIN_CONTENT) || nodeTypeQName.equals(ContentModel.TYPE_CONTENT)) { - fAVMService.createFile(avmPath, nodeName); + OutputStream os = fAVMService.createFile(avmPath, nodeName); + try + { + if (os != null) { os.close(); } + } + catch (IOException ioe) + { + fgLogger.warn("Failed to close output stream when creating file '"+AVMUtil.extendAVMPath(avmPath, nodeName)+"'"+ioe.getMessage()); + } } else if (nodeTypeQName.equals(WCMModel.TYPE_AVM_LAYERED_CONTENT)) { diff --git a/source/java/org/alfresco/repo/avm/AVMRepository.java b/source/java/org/alfresco/repo/avm/AVMRepository.java index a6a307622d..95be647d23 100644 --- a/source/java/org/alfresco/repo/avm/AVMRepository.java +++ b/source/java/org/alfresco/repo/avm/AVMRepository.java @@ -69,6 +69,10 @@ import org.apache.commons.logging.LogFactory; */ public class AVMRepository { + /** The i18n'ized messages */ + private static final String MSG_CYCLE_ON_CREATE = "avm.cycle.create"; + private static final String MSG_CYCLE_ON_LOOKUP = "avm.cycle.lookup"; + private static Log fgLogger = LogFactory.getLog(AVMRepository.class); /** @@ -387,7 +391,7 @@ public class AVMRepository { if (dstPath.indexOf(srcPath) == 0) { - throw new AVMCycleException("Cycle would be created."); + throw new AVMCycleException(MSG_CYCLE_ON_CREATE); } fLookupCount.set(1); try @@ -488,7 +492,7 @@ public class AVMRepository { if (dstPath.indexOf(srcPath) == 0) { - throw new AVMCycleException("Cycle would be created."); + throw new AVMCycleException(MSG_CYCLE_ON_CREATE); } // Lookup the src node. fLookupCount.set(1); @@ -698,10 +702,11 @@ public class AVMRepository */ public void rename(String srcPath, String srcName, String dstPath, String dstName) { - // This is about as ugly as it gets. - if ((dstPath + "/").indexOf(srcPath + srcName + "/") == 0) + String extDst = AVMUtil.extendAVMPath(dstPath, ""); + String extSrc = AVMUtil.extendAVMPath(AVMUtil.extendAVMPath(srcPath, srcName), ""); + if (extDst.indexOf(extSrc) == 0) { - throw new AVMCycleException("Cyclic rename."); + throw new AVMCycleException(MSG_CYCLE_ON_CREATE); } fLookupCount.set(1); String[] pathParts; @@ -1508,7 +1513,7 @@ public class AVMRepository } if (fLookupCount.get() > 50) { - throw new AVMCycleException("Cycle in lookup."); + throw new AVMCycleException(MSG_CYCLE_ON_LOOKUP); } String[] pathParts = SplitPath(path); AVMStore store = getAVMStoreByName(pathParts[0]); @@ -1985,7 +1990,7 @@ public class AVMRepository fLookupCount.set(fLookupCount.get() + 1); if (fLookupCount.get() > 50) { - throw new AVMCycleException("Cycle in lookup."); + throw new AVMCycleException(MSG_CYCLE_ON_LOOKUP); } String[] pathParts = SplitPath(path); AVMStore store = getAVMStoreByName(pathParts[0]); diff --git a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java index bc2a9caac8..02a5694db7 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java @@ -64,6 +64,9 @@ import org.apache.commons.logging.LogFactory; */ public class AVMServiceImpl implements AVMService { + /** The i18n'ized messages */ + private static final String MSG_CYCLE_ON_CREATE = "avm.cycle.create"; + public static final String SYSTEM = "system"; private static Log logger = LogFactory.getLog(AVMServiceImpl.class); @@ -488,7 +491,7 @@ public class AVMServiceImpl implements AVMService if (checkForLDCycle(srcPath, AVMUtil.extendAVMPath(parent, name))) { - throw new AVMCycleException("Cycle in lookup."); + throw new AVMCycleException(MSG_CYCLE_ON_CREATE); } if (logger.isDebugEnabled()) diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java index f4c81e96aa..3b82d145e4 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java @@ -4677,6 +4677,42 @@ public class AVMServiceTest extends AVMServiceTestBase try { setupBasicTree(); + + // -ve test + try + { + // note: without trailing "/" + fService.rename("main:/a", "b", "main:/a/b", "b"); + fail("Renaming folder into itself should cause cycle exception"); + } + catch (AVMCycleException ace) + { + // ignore - expected + } + + // -ve test + try + { + // note: with trailing "/" + fService.rename("main:/a/", "b", "main:/a/b/", "b"); + fail("Renaming folder into itself should cause cycle exception"); + } + catch (AVMCycleException ace) + { + // ignore - expected + } + + // -ve test + try + { + fService.rename("main:/", "a", "main:/a/b", "c"); + fail("Renaming folder tree into itself should cause cycle exception"); + } + catch (AVMCycleException ace) + { + // ignore - expected + } + fService.rename("main:/a", "b", "main:/d/e", "brenamed"); fService.createSnapshot("main", null, null); System.out.println(recursiveList("main", -1, true)); diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java b/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java index 154212f1ef..b7252bc0e7 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java @@ -124,7 +124,7 @@ public class AVMServiceTestBase extends TestCase { public void storeCreated(String name) { - System.err.println("Store created: " + name); + //System.err.println("Store created: " + name); } } ); @@ -134,7 +134,7 @@ public class AVMServiceTestBase extends TestCase { public void storePurged(String name) { - System.err.println("Store purged: " + name); + //System.err.println("Store purged: " + name); } } ); @@ -144,7 +144,7 @@ public class AVMServiceTestBase extends TestCase { public void versionCreated(String name, int versionID) { - System.err.println("Version created: " + name + " " + versionID); + //System.err.println("Version created: " + name + " " + versionID); } } ); @@ -154,7 +154,7 @@ public class AVMServiceTestBase extends TestCase { public void versionPurged(String name, int versionID) { - System.err.println("Version purged: " + name + " " + versionID); + //System.err.println("Version purged: " + name + " " + versionID); } } ); diff --git a/source/java/org/alfresco/repo/avm/OrphanReaper.java b/source/java/org/alfresco/repo/avm/OrphanReaper.java index c4f10f019a..9978e01168 100644 --- a/source/java/org/alfresco/repo/avm/OrphanReaper.java +++ b/source/java/org/alfresco/repo/avm/OrphanReaper.java @@ -260,6 +260,11 @@ public class OrphanReaper { public Object execute() throws Exception { + if (fgLogger.isTraceEnabled()) + { + fgLogger.trace("Orphan reaper doBatch: batchSize="+fBatchSize+", maxQueueLength="+fQueueLength+", fActiveBaseSleep="+fActiveBaseSleep); + } + if (fPurgeQueue == null) { List nodes = AVMDAOs.Instance().fAVMNodeDAO.getOrphans(fQueueLength); @@ -273,30 +278,43 @@ public class OrphanReaper fActive = false; return null; } + fPurgeQueue = new LinkedList(); for (AVMNode node : nodes) { fPurgeQueue.add(node.getId()); } + + if (fgLogger.isDebugEnabled()) + { + fgLogger.debug("Queue was empty so got more orphans from DB. Orphan queue size = "+fPurgeQueue.size()); + } } - - if (fgLogger.isDebugEnabled()) + else { - fgLogger.debug("Found orphan nodes (fpurgeQueue size = "+fPurgeQueue.size()+")"); + if (fgLogger.isDebugEnabled()) + { + fgLogger.debug("Queue was not empty. Orphan queue size = "+fPurgeQueue.size()); + } } fActive = true; + + int reapCnt = 0; + + long start = System.currentTimeMillis(); + for (int i = 0; i < fBatchSize; i++) { if (fPurgeQueue.size() == 0) { - if (fgLogger.isDebugEnabled()) + if (fgLogger.isTraceEnabled()) { - fgLogger.debug("Purge queue is empty (fpurgeQueue size = "+fPurgeQueue.size()+")"); + fgLogger.trace("Purge queue is empty (fpurgeQueue size = "+fPurgeQueue.size()+")"); } fPurgeQueue = null; - return null; + break; } Long nodeId = fPurgeQueue.removeFirst(); @@ -396,7 +414,15 @@ public class OrphanReaper { fgLogger.trace("Deleted Node ["+node.getId()+"]"); } + + reapCnt++; } + + if (fgLogger.isDebugEnabled()) + { + fgLogger.debug("Reaped "+reapCnt+" nodes in "+(System.currentTimeMillis()-start)+" msecs"); + } + return null; } } diff --git a/source/java/org/alfresco/repo/avm/PurgeTestP.java b/source/java/org/alfresco/repo/avm/PurgeTestP.java index 473bab94c2..1439298d38 100644 --- a/source/java/org/alfresco/repo/avm/PurgeTestP.java +++ b/source/java/org/alfresco/repo/avm/PurgeTestP.java @@ -31,19 +31,20 @@ public class PurgeTestP extends AVMServiceTestBase { private static Log logger = LogFactory.getLog(PurgeTestP.class); - public void testSetup() + @Override + public void setUp() throws Exception { - runOrphanReaper(); - } + super.setUp(); + runOrphanReaper(1000, 1000, 0); + } + public void testRemoveNodes() throws Throwable { try { logger.info("testRemoveNodes"); - runOrphanReaper(); - int fileCount = 10; logger.info("Create "+fileCount+" files ..."); @@ -78,8 +79,6 @@ public class PurgeTestP extends AVMServiceTestBase { logger.info("testPurgeVersion"); - runOrphanReaper(); - setupBasicTree(); BulkLoader loader = new BulkLoader(); loader.setAvmService(fService); @@ -113,8 +112,6 @@ public class PurgeTestP extends AVMServiceTestBase { logger.info("testPurgeOlderVersion"); - runOrphanReaper(); - setupBasicTree(); BulkLoader loader = new BulkLoader(); loader.setAvmService(fService); @@ -155,8 +152,6 @@ public class PurgeTestP extends AVMServiceTestBase { logger.info("testPurgeStore"); - runOrphanReaper(); - setupBasicTree(); BulkLoader loader = new BulkLoader(); @@ -194,9 +189,30 @@ public class PurgeTestP extends AVMServiceTestBase } private void runOrphanReaper() + { + // use configured defaults (eg. 50, 1000, 1000) + runOrphanReaper(-1, -1, -1); + } + + private void runOrphanReaper(int batchSize, int maxQueueLength, int activeBaseSleep) { logger.info("Reaper started"); + if (batchSize != -1) + { + fReaper.setBatchSize(batchSize); + } + + if (maxQueueLength != -1) + { + fReaper.setMaxQueueLength(maxQueueLength); + } + + if (activeBaseSleep != -1) + { + fReaper.setActiveBaseSleep(activeBaseSleep); + } + fReaper.activate(); fReaper.execute(); @@ -207,7 +223,7 @@ public class PurgeTestP extends AVMServiceTestBase { try { - //System.out.print("."); + logger.info("Cycle: "+cycles); Thread.sleep(2000); } catch (InterruptedException e) @@ -221,9 +237,24 @@ public class PurgeTestP extends AVMServiceTestBase if (cycles > maxCycles) { - throw new AlfrescoRuntimeException("Orphan reaper still active - failed to clean orphans in "+cycles+" cycles (max "+maxCycles+")"); + throw new AlfrescoRuntimeException("Orphan reaper still active - failed to clean orphans in "+cycles+" wait cycles (max "+maxCycles+")"); } - logger.info("Reaper finished (in "+cycles+" cycles)"); + if (batchSize != -1) + { + fReaper.setBatchSize(50); + } + + if (maxQueueLength != -1) + { + fReaper.setMaxQueueLength(1000); + } + + if (activeBaseSleep != -1) + { + fReaper.setActiveBaseSleep(1000); + } + + logger.info("Reaper finished (in "+cycles+" wait cycles)"); } } diff --git a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java index e330a1a37b..98b414211e 100644 --- a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java +++ b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java @@ -98,6 +98,9 @@ public class SchemaBootstrap extends AbstractLifecycleBean { /** The placeholder for the configured Dialect class name: ${db.script.dialect} */ private static final String PLACEHOLDER_SCRIPT_DIALECT = "\\$\\{db\\.script\\.dialect\\}"; + + /** The global property containing the default batch size used by --FOREACH */ + private static final String PROPERTY_DEFAULT_BATCH_SIZE = "system.upgrade.default.batchsize"; private static final String MSG_DIALECT_USED = "schema.update.msg.dialect_used"; private static final String MSG_BYPASSING_SCHEMA_UPDATE = "schema.update.msg.bypassing"; @@ -203,6 +206,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean private int schemaUpdateLockRetryCount = DEFAULT_LOCK_RETRY_COUNT; private int schemaUpdateLockRetryWaitSeconds = DEFAULT_LOCK_RETRY_WAIT_SECONDS; private int maximumStringLength; + private Properties globalProperties; private ThreadLocal executedStatementsThreadLocal = new ThreadLocal(); private File xmlPreSchemaOutputFile; // This must be set if there are any executed statements @@ -215,6 +219,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean preUpdateScriptPatches = new ArrayList(4); postUpdateScriptPatches = new ArrayList(4); maximumStringLength = -1; + globalProperties = new Properties(); } public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory) @@ -387,6 +392,18 @@ public class SchemaBootstrap extends AbstractLifecycleBean ActionQueue.setMAX_EXECUTIONS_SIZE(hibernateMaxExecutions); } + + /** + * Sets the properties map from which we look up some configuration settings. + * + * @param globalProperties + * the global properties + */ + public void setGlobalProperties(Properties globalProperties) + { + this.globalProperties = globalProperties; + } + /** * Helper method to generate a schema creation SQL script from the given Hibernate * configuration. @@ -968,6 +985,9 @@ public class SchemaBootstrap extends AbstractLifecycleBean StringBuilder sb = new StringBuilder(1024); String fetchVarName = null; String fetchColumnName = null; + boolean doBatch = false; + int batchUpperLimit = 0; + int batchSize = 1; Map varAssignments = new HashMap(13); // Special variable assignments: if (dialect instanceof PostgreSQLDialect) @@ -1017,16 +1037,45 @@ public class SchemaBootstrap extends AbstractLifecycleBean fetchVarName = assigns[0]; fetchColumnName = assigns[1]; continue; + } + // Handle looping control + else if (sql.startsWith("--FOREACH")) + { + // --FOREACH table.column batch.size.property + String[] args = sql.split("[ \\t]+"); + int sepIndex; + if (args.length == 3 && (sepIndex = args[1].indexOf('.')) != -1) + { + doBatch = true; + // Select the upper bound of the table column + String stmt = "SELECT MAX(" + args[1].substring(sepIndex+1) + ") AS upper_limit FROM " + args[1].substring(0, sepIndex); + Object fetchedVal = executeStatement(connection, stmt, "upper_limit", false, line, scriptFile); + if (fetchedVal instanceof Number) + { + batchUpperLimit = ((Number)fetchedVal).intValue(); + // Read the batch size from the named property + String batchSizeString = globalProperties.getProperty(args[2]); + // Fall back to the default property + if (batchSizeString == null) + { + batchSizeString = globalProperties.getProperty(PROPERTY_DEFAULT_BATCH_SIZE); + } + batchSize = batchSizeString == null ? 10000 : Integer.parseInt(batchSizeString); + } + } + continue; } // Allow transaction delineation else if (sql.startsWith("--BEGIN TXN")) { connection.setAutoCommit(false); + continue; } else if (sql.startsWith("--END TXN")) { connection.commit(); - connection.setAutoCommit(true); + connection.setAutoCommit(true); + continue; } // Check for comments @@ -1084,34 +1133,49 @@ public class SchemaBootstrap extends AbstractLifecycleBean // execute, if required if (execute) { - sql = sb.toString(); - - // Perform variable replacement using the ${var} format - for (Map.Entry entry : varAssignments.entrySet()) + // Now substitute and execute the statement the appropriate number of times + String unsubstituted = sb.toString(); + for(int lowerBound = 0; lowerBound <= batchUpperLimit; lowerBound += batchSize) { - String var = entry.getKey(); - Object val = entry.getValue(); - sql = sql.replaceAll("\\$\\{" + var + "\\}", val.toString()); - } - - // Handle the 0/1 values that PostgreSQL doesn't translate to TRUE - if (this.dialect != null && this.dialect instanceof PostgreSQLDialect) - { - sql = sql.replaceAll("\\$\\{TRUE\\}", "TRUE"); - } - else - { - sql = sql.replaceAll("\\$\\{TRUE\\}", "1"); - } - - Object fetchedVal = executeStatement(connection, sql, fetchColumnName, optional, line, scriptFile); - if (fetchVarName != null && fetchColumnName != null) - { - varAssignments.put(fetchVarName, fetchedVal); - } - sb = new StringBuilder(1024); + sql = unsubstituted; + + // Substitute in the next pair of range parameters + if (doBatch) + { + varAssignments.put("LOWERBOUND", String.valueOf(lowerBound)); + varAssignments.put("UPPERBOUND", String.valueOf(lowerBound + batchSize - 1)); + } + + // Perform variable replacement using the ${var} format + for (Map.Entry entry : varAssignments.entrySet()) + { + String var = entry.getKey(); + Object val = entry.getValue(); + sql = sql.replaceAll("\\$\\{" + var + "\\}", val.toString()); + } + + // Handle the 0/1 values that PostgreSQL doesn't translate to TRUE + if (this.dialect != null && this.dialect instanceof PostgreSQLDialect) + { + sql = sql.replaceAll("\\$\\{TRUE\\}", "TRUE"); + } + else + { + sql = sql.replaceAll("\\$\\{TRUE\\}", "1"); + } + + Object fetchedVal = executeStatement(connection, sql, fetchColumnName, optional, line, scriptFile); + if (fetchVarName != null && fetchColumnName != null) + { + varAssignments.put(fetchVarName, fetchedVal); + } + } + sb.setLength(0); fetchVarName = null; fetchColumnName = null; + doBatch = false; + batchUpperLimit = 0; + batchSize = 1; } } } diff --git a/source/java/org/alfresco/repo/imap/AlfrescoImapServer.java b/source/java/org/alfresco/repo/imap/AlfrescoImapServer.java index 066a33de16..3f6458c872 100644 --- a/source/java/org/alfresco/repo/imap/AlfrescoImapServer.java +++ b/source/java/org/alfresco/repo/imap/AlfrescoImapServer.java @@ -19,7 +19,6 @@ package org.alfresco.repo.imap; import org.springframework.extensions.surf.util.AbstractLifecycleBean; -import org.alfresco.repo.admin.SysAdminParams; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationEvent; @@ -39,9 +38,9 @@ public class AlfrescoImapServer extends AbstractLifecycleBean private static Log logger = LogFactory.getLog(AlfrescoImapServer.class); private ImapServer serverImpl; - private SysAdminParams sysAdminParams; private int port = 143; + private String host = "0.0.0.0"; private ImapHostManager imapHostManager; private UserManager imapUserManager; @@ -49,11 +48,6 @@ public class AlfrescoImapServer extends AbstractLifecycleBean private boolean imapServerEnabled; - public void setSysAdminParams(SysAdminParams sysAdminParams) - { - this.sysAdminParams = sysAdminParams; - } - public void setImapServerEnabled(boolean imapServerEnabled) { this.imapServerEnabled = imapServerEnabled; @@ -64,6 +58,11 @@ public class AlfrescoImapServer extends AbstractLifecycleBean this.port = port; } + public void setHost(String host) + { + this.host = host; + } + public void setImapHostManager(ImapHostManager imapHostManager) { this.imapHostManager = imapHostManager; @@ -90,13 +89,12 @@ public class AlfrescoImapServer extends AbstractLifecycleBean return imapUserManager; } }; - String currentHost = sysAdminParams.getAlfrescoHost(); - serverImpl = new ImapServer(new ServerSetup(port, currentHost, ServerSetup.PROTOCOL_IMAP), imapManagers); + serverImpl = new ImapServer(new ServerSetup(port, host, ServerSetup.PROTOCOL_IMAP), imapManagers); serverImpl.startService(null); if (logger.isInfoEnabled()) { - logger.info("IMAP service started on host:port " + currentHost + ":" + this.port + "."); + logger.info("IMAP service started on host:port " + host + ":" + this.port + "."); } } else diff --git a/source/java/org/alfresco/repo/model/filefolder/FileFolderPerformanceTester.java b/source/java/org/alfresco/repo/model/filefolder/FileFolderPerformanceTester.java index 6d2fb0295c..093c4b7f0f 100644 --- a/source/java/org/alfresco/repo/model/filefolder/FileFolderPerformanceTester.java +++ b/source/java/org/alfresco/repo/model/filefolder/FileFolderPerformanceTester.java @@ -74,29 +74,50 @@ public class FileFolderPerformanceTester extends TestCase { private static Log logger = LogFactory.getLog(FileFolderPerformanceTester.class); - private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + protected static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); + + protected RetryingTransactionHelper retryingTransactionHelper; + protected NodeService nodeService; - private RetryingTransactionHelper retryingTransactionHelper; private AuthenticationComponent authenticationComponent; - private NodeService nodeService; private FileFolderService fileFolderService; + private SearchService searchService; private NodeRef rootFolderRef; private File dataFile; + + protected NodeService getNodeService() + { + return (NodeService)ctx.getBean("NodeService"); + } + @Override public void setUp() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); - nodeService = serviceRegistry.getNodeService(); + fileFolderService = serviceRegistry.getFileFolderService(); - SearchService searchService = serviceRegistry.getSearchService(); + searchService = serviceRegistry.getSearchService(); + nodeService = getNodeService(); // authenticate authenticationComponent.setSystemUserAsCurrentUser(); - // find the guest folder + rootFolderRef = getOrCreateRootFolder(); + + dataFile = AbstractContentTransformerTest.loadQuickTestFile("txt"); + } + + public void testSetUp() throws Exception + { + assertNotNull(dataFile); + } + + protected NodeRef getOrCreateRootFolder() + { + // find the guest folder StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); ResultSet rs = searchService.query(storeRef, SearchService.LANGUAGE_XPATH, "/app:company_home"); try @@ -106,7 +127,7 @@ public class FileFolderPerformanceTester extends TestCase throw new AlfrescoRuntimeException("Didn't find Company Home"); } NodeRef companyHomeNodeRef = rs.getNodeRef(0); - rootFolderRef = fileFolderService.create( + return fileFolderService.create( companyHomeNodeRef, getName() + "_" + System.currentTimeMillis(), ContentModel.TYPE_FOLDER).getNodeRef(); @@ -115,12 +136,6 @@ public class FileFolderPerformanceTester extends TestCase { rs.close(); } - dataFile = AbstractContentTransformerTest.loadQuickTestFile("txt"); - } - - public void testSetUp() throws Exception - { - assertNotNull(dataFile); } /** @@ -325,13 +340,13 @@ public class FileFolderPerformanceTester extends TestCase } } } - + // /** Load 5000 files into a single folder using 2 threads */ // public void test_2_ordered_1_2500() throws Exception // { // buildStructure(rootFolderRef, 2, false, 1, 2500, new double[] {0.25, 0.50, 0.75}); // } - + // public void test_4_ordered_10_100() throws Exception // { // buildStructure(rootFolderRef, 4, false, 10, 100, new double[] {0.25, 0.50, 0.75}); @@ -381,7 +396,7 @@ public class FileFolderPerformanceTester extends TestCase // 50000, // new double[] {0.01, 0.02, 0.03, 0.04, 0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90}); // } - + /** * Create a bunch of files and folders in a folder and then run multi-threaded directory diff --git a/source/java/org/alfresco/repo/node/index/NodeIndexer.java b/source/java/org/alfresco/repo/node/index/NodeIndexer.java index 195910fd9f..01d080ac76 100644 --- a/source/java/org/alfresco/repo/node/index/NodeIndexer.java +++ b/source/java/org/alfresco/repo/node/index/NodeIndexer.java @@ -82,6 +82,10 @@ public class NodeIndexer { if (enabled) { + if (logger.isDebugEnabled()) + { + logger.debug("indexCreateNode", new Exception("Stack Trace")); + } indexer.createNode(childAssocRef); } } @@ -90,6 +94,10 @@ public class NodeIndexer { if (enabled) { + if (logger.isDebugEnabled()) + { + logger.debug("indexUpdateNode", new Exception("Stack Trace")); + } indexer.updateNode(nodeRef); } } @@ -98,6 +106,10 @@ public class NodeIndexer { if (enabled) { + if (logger.isDebugEnabled()) + { + logger.debug("indexDeleteNode", new Exception("Stack Trace")); + } indexer.deleteNode(childAssocRef); } } @@ -106,6 +118,10 @@ public class NodeIndexer { if (enabled) { + if (logger.isDebugEnabled()) + { + logger.debug("indexCreateChildAssociation", new Exception("Stack Trace")); + } indexer.createChildRelationship(childAssocRef); } } @@ -114,6 +130,10 @@ public class NodeIndexer { if (enabled) { + if (logger.isDebugEnabled()) + { + logger.debug("indexDeleteChildAssociation", new Exception("Stack Trace")); + } indexer.deleteChildRelationship(childAssocRef); } } @@ -122,6 +142,10 @@ public class NodeIndexer { if (enabled) { + if (logger.isDebugEnabled()) + { + logger.debug("indexUpdateChildAssociation", new Exception("Stack Trace")); + } indexer.updateChildRelationship(oldChildAssocRef, newChildAssocRef); } } diff --git a/source/java/org/alfresco/repo/search/AVMSnapShotTriggeredIndexingMethodInterceptor.java b/source/java/org/alfresco/repo/search/AVMSnapShotTriggeredIndexingMethodInterceptor.java index f802f0aafb..4ca142eba5 100644 --- a/source/java/org/alfresco/repo/search/AVMSnapShotTriggeredIndexingMethodInterceptor.java +++ b/source/java/org/alfresco/repo/search/AVMSnapShotTriggeredIndexingMethodInterceptor.java @@ -34,6 +34,8 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * Method interceptor for atomic indexing of AVM entries The properties can defined how stores are indexed based on type @@ -44,6 +46,8 @@ import org.aopalliance.intercept.MethodInvocation; */ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInterceptor { + private static Log logger = LogFactory.getLog(AVMSnapShotTriggeredIndexingMethodInterceptor.class); + // Copy of store properties used to tag avm stores (a store propertry) public final static QName PROP_SANDBOX_STAGING_MAIN = QName.createQName(null, ".sandbox.staging.main"); @@ -106,6 +110,10 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte AVMLuceneIndexer avmIndexer = getIndexer(store); if (avmIndexer != null) { + if (logger.isDebugEnabled()) + { + logger.debug("purgeStore " + store, new Exception("Stack Trace")); + } avmIndexer.deleteIndex(store, IndexMode.SYNCHRONOUS); } } @@ -133,6 +141,10 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte AVMLuceneIndexer avmIndexer = getIndexer(from); if (avmIndexer != null) { + if (logger.isDebugEnabled()) + { + logger.debug("renameStore deleteIndex " + from, new Exception("Stack Trace")); + } avmIndexer.deleteIndex(from, IndexMode.SYNCHRONOUS); } } @@ -142,6 +154,10 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte AVMLuceneIndexer avmIndexer = getIndexer(to); if (avmIndexer != null) { + if (logger.isDebugEnabled()) + { + logger.debug("renameStore createIndex " + to, new Exception("Stack Trace")); + } avmIndexer.createIndex(to, IndexMode.SYNCHRONOUS); avmIndexer.index(to, 0, after, getIndexMode(to)); } @@ -258,6 +274,10 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte } int from = before != -1 ? before : last; + if (logger.isDebugEnabled()) + { + logger.debug("indexSnapshotImpl " + store, new Exception("Stack Trace")); + } avmIndexer.index(store, from, after, getIndexMode(store)); } } @@ -503,6 +523,10 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte AVMLuceneIndexer avmIndexer = getIndexer(store); if (avmIndexer != null) { + if (logger.isDebugEnabled()) + { + logger.debug("createIndex " + store, new Exception("Stack Trace")); + } avmIndexer.createIndex(store, IndexMode.SYNCHRONOUS); } } diff --git a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java index cedb64b200..497573b028 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java @@ -3318,20 +3318,16 @@ public class IndexInfo implements IndexMonitor if (!mergingIndexes && !applyingDeletions) { - if ((indexes > mergerMergeFactor) || (deltas > mergerTargetOverlays)) + if (indexes > mergerMergeFactor) { - if (indexes > deltas) - { - // Try merge - action = MergeAction.MERGE_INDEX; - } - else - { - // Try delete - action = MergeAction.APPLY_DELTA_DELETION; - - } + // Try merge + action = MergeAction.MERGE_INDEX; } + else if (deltas > mergerTargetOverlays) + { + // Try delete + action = MergeAction.APPLY_DELTA_DELETION; + } } }