mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
[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:
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -125,10 +125,12 @@ public class ContentStoreCleaner
|
|||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
private int protectDays;
|
private int protectDays;
|
||||||
|
private int batchSize;
|
||||||
private DeleteFailureAction deletionFailureAction;
|
private DeleteFailureAction deletionFailureAction;
|
||||||
|
|
||||||
public ContentStoreCleaner()
|
public ContentStoreCleaner()
|
||||||
{
|
{
|
||||||
|
this.batchSize = 1000;
|
||||||
this.protectDays = 7;
|
this.protectDays = 7;
|
||||||
this.deletionFailureAction = DeleteFailureAction.IGNORE;
|
this.deletionFailureAction = DeleteFailureAction.IGNORE;
|
||||||
}
|
}
|
||||||
@@ -192,6 +194,16 @@ public class ContentStoreCleaner
|
|||||||
this.protectDays = protectDays;
|
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.
|
* Set the action to take in the event that an orphaned binary failed to get deleted.
|
||||||
* The default is {@link DeleteFailureAction#IGNORE}.
|
* The default is {@link DeleteFailureAction#IGNORE}.
|
||||||
@@ -329,7 +341,7 @@ public class ContentStoreCleaner
|
|||||||
{
|
{
|
||||||
public Long execute() throws Exception
|
public Long execute() throws Exception
|
||||||
{
|
{
|
||||||
return cleanBatch(maxOrphanTime, 1000);
|
return cleanBatch(maxOrphanTime, batchSize);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
while (true)
|
while (true)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* 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
|
public class ContentUrlOrphanQuery
|
||||||
{
|
{
|
||||||
private Long maxOrphanTimeExclusive;
|
private Long maxOrphanTimeExclusive;
|
||||||
|
private Long maxRecords;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
@@ -41,6 +42,7 @@ public class ContentUrlOrphanQuery
|
|||||||
StringBuilder sb = new StringBuilder(512);
|
StringBuilder sb = new StringBuilder(512);
|
||||||
sb.append("ContentUrlOrphanQuery")
|
sb.append("ContentUrlOrphanQuery")
|
||||||
.append("[ maxOrphanTimeExclusive=").append(maxOrphanTimeExclusive)
|
.append("[ maxOrphanTimeExclusive=").append(maxOrphanTimeExclusive)
|
||||||
|
.append(", maxRecords=").append(maxRecords)
|
||||||
.append("]");
|
.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@@ -53,5 +55,17 @@ public class ContentUrlOrphanQuery
|
|||||||
public void setMaxOrphanTimeExclusive(Long maxOrphanTimeExclusive)
|
public void setMaxOrphanTimeExclusive(Long maxOrphanTimeExclusive)
|
||||||
{
|
{
|
||||||
this.maxOrphanTimeExclusive = maxOrphanTimeExclusive;
|
this.maxOrphanTimeExclusive = maxOrphanTimeExclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getMaxRecords()
|
||||||
|
{
|
||||||
|
return maxRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxRecords(Long maxRecords)
|
||||||
|
{
|
||||||
|
this.maxRecords = maxRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* 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();
|
ContentUrlOrphanQuery query = new ContentUrlOrphanQuery();
|
||||||
query.setMaxOrphanTimeExclusive(maxOrphanTimeExclusive);
|
query.setMaxOrphanTimeExclusive(maxOrphanTimeExclusive);
|
||||||
|
query.setMaxRecords((long) maxResults);
|
||||||
List<ContentUrlEntity> results = template.selectList(SELECT_CONTENT_URLS_ORPHANED,
|
List<ContentUrlEntity> results = template.selectList(SELECT_CONTENT_URLS_ORPHANED,
|
||||||
query,
|
query,
|
||||||
new RowBounds(0, maxResults));
|
new RowBounds(0, maxResults));
|
||||||
|
@@ -115,6 +115,9 @@
|
|||||||
<property name="transactionService" >
|
<property name="transactionService" >
|
||||||
<ref bean="transactionService" />
|
<ref bean="transactionService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="batchSize" >
|
||||||
|
<value>${system.content.cleanerBatchSize}</value>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="eagerContentStoreCleaner" class="org.alfresco.repo.content.cleanup.EagerContentStoreCleaner" init-method="init">
|
<bean id="eagerContentStoreCleaner" class="org.alfresco.repo.content.cleanup.EagerContentStoreCleaner" init-method="init">
|
||||||
|
@@ -18,9 +18,10 @@
|
|||||||
left outer join alf_content_data cd on (cd.content_url_id = cu.id)
|
left outer join alf_content_data cd on (cd.content_url_id = cu.id)
|
||||||
where
|
where
|
||||||
cd.id is null and
|
cd.id is null and
|
||||||
|
cu.orphan_time is not null and
|
||||||
cu.orphan_time > 0 and
|
cu.orphan_time > 0 and
|
||||||
cu.orphan_time < #{maxOrphanTimeExclusive} and
|
cu.orphan_time < #{maxOrphanTimeExclusive}
|
||||||
cu.orphan_time is not null
|
limit #{maxRecords}
|
||||||
]]>
|
]]>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
cu.orphan_time > 0 and
|
cu.orphan_time > 0 and
|
||||||
cu.orphan_time < #{maxOrphanTimeExclusive} and
|
cu.orphan_time < #{maxOrphanTimeExclusive} and
|
||||||
cu.orphan_time is not null
|
cu.orphan_time is not null
|
||||||
|
limit #{maxRecords}
|
||||||
]]>
|
]]>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -219,6 +219,8 @@ system.content.orphanProtectDays=14
|
|||||||
system.content.deletionFailureAction=IGNORE
|
system.content.deletionFailureAction=IGNORE
|
||||||
# The CRON expression to trigger the deletion of resources associated with orphaned content.
|
# The CRON expression to trigger the deletion of resources associated with orphaned content.
|
||||||
system.content.orphanCleanup.cronExpression=0 0 4 * * ?
|
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
|
# The CRON expression to trigger the cleanup of deleted nodes and dangling transactions that are old enough
|
||||||
system.nodeServiceCleanup.cronExpression=0 0 21 * * ?
|
system.nodeServiceCleanup.cronExpression=0 0 21 * * ?
|
||||||
|
Reference in New Issue
Block a user