PurgeConflictsHistoricalTask.java revision 90f97a8328fb2433989b4ac05dd565dc6b4db4bc
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2013-2015 ForgeRock AS
*/
/**
* This class provides an implementation of a Directory Server task that can
* be used to purge the replication historical informations stored in the
* user entries to solve conflicts.
*/
public class PurgeConflictsHistoricalTask extends Task
{
/** The default value for the maximum duration of the purge expressed in seconds. */
private String domainString;
private LDAPReplicationDomain domain;
/**
* current historical purge delay
* <--------------------------------->
* -----------------------------------------------------------------> t
* | | |
* current task task
* CSN being purged start date max end date
* <------------>
* config.purgeMaxDuration
*
* The task will start purging the change with the oldest CSN found.
* The task run as long as :
* - the end date (computed from the configured max duration) is not reached
* - the CSN purged is oldest than the configured historical purge delay
*/
private int purgeTaskMaxDurationInSec = DEFAULT_MAX_DURATION;
/** {@inheritDoc} */
public LocalizableMessage getDisplayName() {
}
/** {@inheritDoc} */
{
{
return;
}
// FIXME -- Do we need any special authorization here?
try
{
// We can assume that this is an LDAP replication domain
}
catch(DirectoryException e)
{
}
AttributeType typeMaxDuration = getAttributeTypeOrDefault(ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION);
if (maxDurationStringInSec != null)
{
try
{
}
catch(Exception e)
{
throw new DirectoryException(
}
}
}
/** {@inheritDoc} */
{
Boolean purgeCompletedInTime = false;
try
{
replaceAttributeValue(ATTR_TASK_CONFLICTS_HIST_PURGE_COMPLETED_IN_TIME, purgeCompletedInTime.toString());
// launch the task
purgeCompletedInTime = true;
replaceAttributeValue(ATTR_TASK_CONFLICTS_HIST_PURGE_COMPLETED_IN_TIME, purgeCompletedInTime.toString());
}
catch(DirectoryException de)
{
{
// Error raised at submission time
}
else
{
}
}
finally
{
try
{
// sets in the attributes the last stats values
}
catch(Exception e)
{
}
}
return initState;
}
private int updateAttrPeriod;
private int purgeCount;
/**
* Set the last CSN purged and the count of purged values in order to monitor
* the historical purge.
*
* @param lastCSN
* the last CSN purged.
* @param purgeCount
* the count of purged values.
*/
{
try
{
if (purgeCount == 0)
{
}
// we don't want the update of the task to overload too much task duration
this.purgeCount = purgeCount;
{
}
}
catch(DirectoryException de)
{
}
}
}