[REPO-5592] Support for PostgreSQL and MySQL, batch size is now configurable (#485)

* Initial support for PosgreSQL, MySQL plus batchSize is now configurable

* Changes post review
This commit is contained in:
Bruno Bossola
2021-05-24 11:46:00 +01:00
committed by GitHub
parent 71f3cd493b
commit 3648c98e4b
7 changed files with 41 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -125,10 +125,12 @@ public class ContentStoreCleaner
private ContentService contentService;
private TransactionService transactionService;
private int protectDays;
private int batchSize;
private DeleteFailureAction deletionFailureAction;
public ContentStoreCleaner()
{
this.batchSize = 1000;
this.protectDays = 7;
this.deletionFailureAction = DeleteFailureAction.IGNORE;
}
@@ -192,6 +194,16 @@ public class ContentStoreCleaner
this.protectDays = protectDays;
}
/**
* Set the batch size used by the cleaning jobs. The default is 1000
*
* @param batchSize batch size for each cleanup job
*/
public void setBatchSize(int batchSize)
{
this.batchSize = batchSize;
}
/**
* Set the action to take in the event that an orphaned binary failed to get deleted.
* The default is {@link DeleteFailureAction#IGNORE}.
@@ -329,7 +341,7 @@ public class ContentStoreCleaner
{
public Long execute() throws Exception
{
return cleanBatch(maxOrphanTime, 1000);
return cleanBatch(maxOrphanTime, batchSize);
};
};
while (true)

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -34,6 +34,7 @@ package org.alfresco.repo.domain.contentdata;
public class ContentUrlOrphanQuery
{
private Long maxOrphanTimeExclusive;
private Long maxRecords;
@Override
public String toString()
@@ -41,6 +42,7 @@ public class ContentUrlOrphanQuery
StringBuilder sb = new StringBuilder(512);
sb.append("ContentUrlOrphanQuery")
.append("[ maxOrphanTimeExclusive=").append(maxOrphanTimeExclusive)
.append(", maxRecords=").append(maxRecords)
.append("]");
return sb.toString();
}
@@ -53,5 +55,17 @@ public class ContentUrlOrphanQuery
public void setMaxOrphanTimeExclusive(Long maxOrphanTimeExclusive)
{
this.maxOrphanTimeExclusive = maxOrphanTimeExclusive;
}
}
public Long getMaxRecords()
{
return maxRecords;
}
public void setMaxRecords(Long maxRecords)
{
this.maxRecords = maxRecords;
}
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -155,6 +155,7 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl
ContentUrlOrphanQuery query = new ContentUrlOrphanQuery();
query.setMaxOrphanTimeExclusive(maxOrphanTimeExclusive);
query.setMaxRecords((long) maxResults);
List<ContentUrlEntity> results = template.selectList(SELECT_CONTENT_URLS_ORPHANED,
query,
new RowBounds(0, maxResults));

View File

@@ -115,6 +115,9 @@
<property name="transactionService" >
<ref bean="transactionService" />
</property>
<property name="batchSize" >
<value>${system.content.cleanerBatchSize}</value>
</property>
</bean>
<bean id="eagerContentStoreCleaner" class="org.alfresco.repo.content.cleanup.EagerContentStoreCleaner" init-method="init">

View File

@@ -18,9 +18,10 @@
left outer join alf_content_data cd on (cd.content_url_id = cu.id)
where
cd.id is null and
cu.orphan_time is not null and
cu.orphan_time > 0 and
cu.orphan_time < #{maxOrphanTimeExclusive} and
cu.orphan_time is not null
cu.orphan_time < #{maxOrphanTimeExclusive}
limit #{maxRecords}
]]>
</select>

View File

@@ -21,6 +21,7 @@
cu.orphan_time > 0 and
cu.orphan_time < #{maxOrphanTimeExclusive} and
cu.orphan_time is not null
limit #{maxRecords}
]]>
</select>

View File

@@ -219,6 +219,8 @@ system.content.orphanProtectDays=14
system.content.deletionFailureAction=IGNORE
# The CRON expression to trigger the deletion of resources associated with orphaned content.
system.content.orphanCleanup.cronExpression=0 0 4 * * ?
# The batch size user by the content store cleaner
system.content.cleanerBatchSize=1000
# The CRON expression to trigger the cleanup of deleted nodes and dangling transactions that are old enough
system.nodeServiceCleanup.cronExpression=0 0 21 * * ?