/* (non-Javadoc)
* @see org.apache.directory.server.core.partition.PartitionNexus#sync()
*/
public void sync() throws Exception
{
MultiException error = null;
// store the contextCSN value in the entry ou=system
// note that this modification shouldn't change the entryCSN value of ou=system entry
try
{
String currentCtxCsn = directoryService.getContextCsn();
// update only if the CSN changes
if ( ( currentCtxCsn != null ) && !currentCtxCsn.equals( lastSyncedCtxCsn ) )
{
lastSyncedCtxCsn = currentCtxCsn;
Attribute contextCsnAt = mods.get( 0 ).getAttribute();
contextCsnAt.clear();
contextCsnAt.add( lastSyncedCtxCsn );
Attribute timeStampAt = mods.get( 1 ).getAttribute();
timeStampAt.clear();
timeStampAt.add( DateUtils.getGeneralizedTime() );
ModifyOperationContext csnModContext = new ModifyOperationContext( directoryService.getAdminSession(),
directoryService.getSystemPartition().getSuffixDn(), mods );
directoryService.getSystemPartition().modify( csnModContext );
}
}
catch ( Exception e )
{
LOG.warn( "Failed to save the contextCSN attribute value in ou=system entry.", e );
if ( error == null )
{
error = new MultiException( I18n.err( I18n.ERR_265 ) );
}
error.addThrowable( e );
}
for ( Partition partition : this.partitions.values() )
{
try
{
partition.sync();
}
catch ( Exception e )
{
LOG.warn( "Failed to flush partition data out.", e );
if ( error == null )
{
//noinspection ThrowableInstanceNeverThrown
error = new MultiException( I18n.err( I18n.ERR_265 ) );
}
// @todo really need to send this info to a monitor
error.addThrowable( e );
}
}
if ( error != null )
{