// modify the filter to include the context Csn
ExprNode initialContentFilter = new AndNode( modifiedFilter, csnNode );
request.setFilter( initialContentFilter );
// Now, do a search to get all the entries
SearchResultDone searchDoneResp = doSimpleSearch( session, request, replicaLog );
if ( searchDoneResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
if ( replicaLog.getLastSentCsn() == null )
{
replicaLog.setLastSentCsn( contextCsn );
}
if ( refreshNPersist ) // refreshAndPersist mode
{
PROVIDER_LOG
.debug( "Refresh&Persist requested : send the data being modified since the initial refresh" );
// Now, send the modified entries since the search has started
sendContentFromLog( session, request, replicaLog, contextCsn );
byte[] cookie = LdapProtocolUtils.createCookie( replicaLog.getId(), replicaLog.getLastSentCsn() );
IntermediateResponse intermResp = new IntermediateResponseImpl( request.getMessageId() );
intermResp.setResponseName( SyncInfoValue.OID );
SyncInfoValue syncInfo = new SyncInfoValueDecorator(
ldapServer.getDirectoryService().getLdapCodecService(), SynchronizationInfoEnum.NEW_COOKIE );
syncInfo.setCookie( cookie );
intermResp.setResponseValue( ( ( SyncInfoValueDecorator ) syncInfo ).getValue() );
PROVIDER_LOG.info( "Sending the intermediate response to consumer {}, {}", replicaLog, syncInfo );
session.getIoSession().write( intermResp );
// switch the handler mode to realtime push
replicationListener.setPushInRealTime( refreshNPersist );
PROVIDER_LOG.debug( "e waiting for any modification for {}", replicaLog );
}
else
{
PROVIDER_LOG.debug( "RefreshOnly requested" );
byte[] cookie = LdapProtocolUtils.createCookie( replicaLog.getId(), contextCsn );
// no need to send from the log, that will be done in the next refreshOnly session
SyncDoneValue syncDone = new SyncDoneValueDecorator(
ldapServer.getDirectoryService().getLdapCodecService() );
syncDone.setCookie( cookie );
searchDoneResp.addControl( syncDone );
PROVIDER_LOG.info( "Sending the searchResultDone response to consumer {}, {}", replicaLog,
searchDoneResp );
session.getIoSession().write( searchDoneResp );
}
}
else
// if not succeeded return
{
PROVIDER_LOG.warn( "initial content refresh didn't succeed due to {}", searchDoneResp.getLdapResult()
.getResultCode() );
replicaLog.stop();
replicaLog = null;
// remove the listener