You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/08/09 10:24:54 UTC
svn commit: r1155254 -
/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/
Author: elecharny
Date: Tue Aug 9 08:24:54 2011
New Revision: 1155254
URL: http://svn.apache.org/viewvc?rev=1155254&view=rev
Log:
o Added missing Javadoc
o Added some commented sysout
Modified:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationTrustManager.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationTrustManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationTrustManager.java?rev=1155254&r1=1155253&r2=1155254&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationTrustManager.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationTrustManager.java Tue Aug 9 08:24:54 2011
@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
*/
public class ReplicationTrustManager implements X509TrustManager
{
+ /** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( ReplicationTrustManager.class );
/** the internal trust manager used for verifying the certificates */
@@ -65,6 +66,9 @@ public class ReplicationTrustManager imp
private static ReplicationTrustManager INSTANCE = new ReplicationTrustManager();
+ /**
+ * Creates a instance of ReplicationTrustManager
+ */
private ReplicationTrustManager()
{
try
@@ -148,18 +152,27 @@ public class ReplicationTrustManager imp
}
+ /**
+ * {@inheritDoc}
+ */
public void checkClientTrusted( X509Certificate[] chain, String authType ) throws CertificateException
{
trustManager.checkClientTrusted( chain, authType );
}
+ /**
+ * {@inheritDoc}
+ */
public void checkServerTrusted( X509Certificate[] chain, String authType ) throws CertificateException
{
trustManager.checkServerTrusted( chain, authType );
}
+ /**
+ * {@inheritDoc}
+ */
public X509Certificate[] getAcceptedIssuers()
{
return trustManager.getAcceptedIssuers();
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=1155254&r1=1155253&r2=1155254&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java Tue Aug 9 08:24:54 2011
@@ -331,15 +331,20 @@ public class SyncReplConsumer implements
switch ( state )
{
case ADD:
- if ( !session.exists( remoteEntry.getDn() ) )
+ Dn remoteDn = directoryService.getDnFactory().create( remoteEntry.getDn().getName() );
+ //System.out.println( " ============> ADDING " + remoteDn );
+
+ if ( !session.exists( remoteDn ) )
{
- LOG.debug( "adding entry with dn {}", remoteEntry.getDn().getName() );
+ //System.out.println( "C: " + remoteDn + " does not exist, adding it" );
+ LOG.debug( "adding entry with dn {}", remoteDn );
LOG.debug( remoteEntry.toString() );
session.add( new DefaultEntry( schemaManager, remoteEntry ) );
}
else
{
- LOG.debug( "updating entry in refreshOnly mode {}", remoteEntry.getDn().getName() );
+ //System.out.println( "C: " + remoteDn + " exists, modifying it" );
+ LOG.debug( "updating entry in refreshOnly mode {}", remoteDn );
modify( remoteEntry );
}
@@ -347,16 +352,20 @@ public class SyncReplConsumer implements
case MODIFY:
LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getName() );
+ //System.out.println( "C: modifying " + remoteEntry.getDn() );
modify( remoteEntry );
break;
case MODDN:
SyncModifyDn adsModDnControl = ( SyncModifyDn ) syncResult.getControls().get( SyncModifyDn.OID );
+ //System.out.println( "C: MODDN " + adsModDnControl.getModDnType() + ", " + adsModDnControl.getEntryDn()
+ // + ", " + adsModDnControl.getNewSuperiorDn() + ", " + adsModDnControl.getNewRdn() );
//Apache Directory Server's special control
applyModDnOperation( adsModDnControl );
break;
case DELETE:
+ //System.out.println( " ============> DELETING " + remoteEntry.getDn().getNormName() );
LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getName() );
// incase of a MODDN operation resulting in a branch to be moved out of scope
// ApacheDS replication provider sends a single delete event on the Dn of the moved branch
@@ -556,12 +565,15 @@ public class SyncReplConsumer implements
SearchFuture sf = connection.searchAsync( searchRequest );
Response resp = sf.get();
-
+
while ( !( resp instanceof SearchResultDone ) && !sf.isCancelled() && !disconnected )
{
if ( resp instanceof SearchResultEntry )
{
- handleSearchResult( ( SearchResultEntry ) resp );
+ SearchResultEntry result = ( SearchResultEntry ) resp;
+ //System.out.println( "++++++++++++> Consumer has received : " + result.getEntry().getDn() );
+
+ handleSearchResult( result );
}
else if ( resp instanceof SearchResultReference )
{
@@ -782,19 +794,22 @@ public class SyncReplConsumer implements
SyncModifyDnType modDnType = modDnControl.getModDnType();
- Dn entryDn = new Dn( modDnControl.getEntryDn() );
+ Dn entryDn = directoryService.getDnFactory().create( modDnControl.getEntryDn() );
+
switch ( modDnType )
{
case MOVE:
+ //System.out.println( " ============> MOVING " + entryDn.getNormName() + " to " + modDnControl.getNewSuperiorDn() );
LOG.debug( "moving {} to the new parent {}", entryDn, modDnControl.getNewSuperiorDn() );
- session.move( entryDn, new Dn( modDnControl.getNewSuperiorDn() ) );
+ session.move( entryDn, directoryService.getDnFactory().create( modDnControl.getNewSuperiorDn() ) );
break;
case RENAME:
- Rdn newRdn = new Rdn( modDnControl.getNewRdn() );
+ //System.out.println( " ============> RENAMING " + entryDn.getNormName() + " to " + modDnControl.getNewRdn() );
+ Rdn newRdn = new Rdn( schemaManager, modDnControl.getNewRdn() );
boolean deleteOldRdn = modDnControl.isDeleteOldRdn();
LOG.debug( "renaming the Dn {} with new Rdn {} and deleteOldRdn flag set to {}", new String[]
{ entryDn.getName(), newRdn.getName(), String.valueOf( deleteOldRdn ) } );
@@ -804,9 +819,10 @@ public class SyncReplConsumer implements
case MOVEANDRENAME:
- Dn newParentDn = new Dn( modDnControl.getNewSuperiorDn() );
- newRdn = new Rdn( modDnControl.getNewRdn() );
+ Dn newParentDn = directoryService.getDnFactory().create( modDnControl.getNewSuperiorDn() );
+ newRdn = new Rdn( schemaManager, modDnControl.getNewRdn() );
deleteOldRdn = modDnControl.isDeleteOldRdn();
+ //System.out.println( " ============> MOVING and RENAMING " + entryDn.getNormName() + " to " + newRdn + "/" +modDnControl.getNewRdn() );
LOG.debug(
"moveAndRename on the Dn {} with new newParent Dn {}, new Rdn {} and deleteOldRdn flag set to {}",
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java?rev=1155254&r1=1155253&r2=1155254&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplRequestHandler.java Tue Aug 9 08:24:54 2011
@@ -257,6 +257,7 @@ public class SyncReplRequestHandler impl
{
try
{
+ //System.out.println( "Init replication on Provider" );
// First extract the Sync control from the request
SyncRequestValue syncControl = ( SyncRequestValue ) request.getControls().get(
SyncRequestValue.OID );
@@ -283,6 +284,7 @@ public class SyncReplRequestHandler impl
else
{
ReplicaEventLog clientMsgLog = getReplicaEventLog( cookieString );
+
if ( clientMsgLog == null )
{
LOG.warn( "received a valid cookie {} but there is no event log associated with this replica",
@@ -291,6 +293,7 @@ public class SyncReplRequestHandler impl
}
else
{
+ //System.out.println( " -> We have events" );
String consumerCsn = getCsn( cookieString );
doContentUpdate( session, request, clientMsgLog, consumerCsn );
}
@@ -316,12 +319,16 @@ public class SyncReplRequestHandler impl
String lastSentCsn = clientMsgLog.getLastSentCsn();
ReplicaEventLogCursor cursor = clientMsgLog.getCursor( consumerCsn );
+ //int i = 0;
while ( cursor.next() )
{
ReplicaEventMessage message = cursor.get();
Entry entry = message.getEntry();
LOG.debug( "received message from the queue {}", entry );
+ //i++;
+
+ //System.out.println( "/////////////-> Message(" + i + ") read from queue : " + message.getEventType() + "/" + entry.getDn() );
lastSentCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ).getString();
@@ -379,6 +386,7 @@ public class SyncReplRequestHandler impl
if ( refreshNPersist )
{
+ //System.out.println( " --> In doContenUpdate, RNP " );
IntermediateResponse intermResp = new IntermediateResponseImpl( req.getMessageId() );
intermResp.setResponseName( SyncInfoValue.OID );
@@ -394,6 +402,7 @@ public class SyncReplRequestHandler impl
}
else
{
+ //System.out.println( " --> In doContenUpdate, RO " );
SearchResultDone searchDoneResp = ( SearchResultDone ) req.getResultResponse();
searchDoneResp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
SyncDoneValue syncDone = new SyncDoneValueDecorator(
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java?rev=1155254&r1=1155253&r2=1155254&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplSearchListener.java Tue Aug 9 08:24:54 2011
@@ -203,8 +203,11 @@ public class SyncReplSearchListener impl
{
Entry entry = addContext.getEntry();
+ LOG.debug( "sending added entry {}", entry.getDn() );
+
try
{
+ //System.out.println( "ADD Listener : log " + entry.getDn() );
// we log it first
consumerMsgLog.log( new ReplicaEventMessage( EventType.ADD, entry ) );
@@ -249,8 +252,11 @@ public class SyncReplSearchListener impl
*/
private void sendDeletedEntry( Entry entry )
{
+ LOG.debug( "sending deleted entry {}", entry.getDn() );
+
try
{
+ //System.out.println( "DELETE Listener : log " + entry.getDn() );
consumerMsgLog.log( new ReplicaEventMessage( EventType.DELETE, entry ) );
if ( pushInRealTime )
@@ -282,8 +288,11 @@ public class SyncReplSearchListener impl
{
Entry alteredEntry = modifyContext.getAlteredEntry();
+ LOG.debug( "sending modified entry {}", alteredEntry.getDn() );
+
try
{
+ //System.out.println( "MODIFY Listener : log " + alteredEntry.getDn() );
consumerMsgLog.log( new ReplicaEventMessage( EventType.MODIFY, alteredEntry ) );
if ( pushInRealTime )
@@ -315,6 +324,8 @@ public class SyncReplSearchListener impl
{
Entry entry = moveContext.getOriginalEntry();
+ LOG.debug( "sending moved entry {}", entry.getDn() );
+
try
{
if ( !moveContext.getNewSuperior().isDescendantOf( consumerMsgLog.getSearchCriteria().getBase() ) )
@@ -328,6 +339,7 @@ public class SyncReplSearchListener impl
modDnControl.setEntryDn( moveContext.getDn().getNormName() );
modDnControl.setNewSuperiorDn( moveContext.getNewSuperior().getNormName() );
+ //System.out.println( "MOVE Listener : log " + moveContext.getDn() + " moved to " + moveContext.getNewSuperior() );
consumerMsgLog.log( new ReplicaEventMessage( modDnControl, entry ) );
if ( pushInRealTime )
@@ -357,6 +369,8 @@ public class SyncReplSearchListener impl
*/
public void entryMovedAndRenamed( MoveAndRenameOperationContext moveAndRenameContext )
{
+ LOG.debug( "sending moveAndRenamed entry {}", moveAndRenameContext.getDn() );
+
try
{
if ( !moveAndRenameContext.getNewSuperiorDn().isDescendantOf( consumerMsgLog.getSearchCriteria().getBase() ) )
@@ -375,6 +389,8 @@ public class SyncReplSearchListener impl
// should always send the original entry cause the consumer perform the modDn operation there
Entry entry = moveAndRenameContext.getOriginalEntry();
+ //System.out.println( "MOVE AND RENAME Listener : log " + moveAndRenameContext.getDn() +
+ // " moved to " + moveAndRenameContext.getNewSuperiorDn() + " renamed to " + moveAndRenameContext.getNewRdn() );
consumerMsgLog.log( new ReplicaEventMessage( modDnControl, entry ) );
if ( pushInRealTime )
@@ -406,6 +422,8 @@ public class SyncReplSearchListener impl
{
Entry entry = renameContext.getOriginalEntry();
+ LOG.debug( "sending renamed entry {}", entry.getDn() );
+
try
{
SyncModifyDnDecorator modDnControl = new SyncModifyDnDecorator( directoryService.getLdapCodecService() );
@@ -415,6 +433,7 @@ public class SyncReplSearchListener impl
modDnControl.setDeleteOldRdn( renameContext.getDeleteOldRdn() );
// should always send the original entry cause the consumer perform the modDn operation there
+ //System.out.println( "RENAME Listener : log " + renameContext.getDn() + " renamed to " + renameContext.getNewRdn() );
consumerMsgLog.log( new ReplicaEventMessage( modDnControl, entry ) );
if ( pushInRealTime )
@@ -506,4 +525,4 @@ public class SyncReplSearchListener impl
return sb.toString();
}
-}
\ No newline at end of file
+}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java?rev=1155254&r1=1155253&r2=1155254&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncreplConfiguration.java Tue Aug 9 08:24:54 2011
@@ -126,6 +126,9 @@ public class SyncreplConfiguration imple
private X509TrustManager trustManager = new NoVerificationTrustManager();
+ /**
+ * Creates a new instance of SyncreplConfiguration
+ */
public SyncreplConfiguration()
{
attributes = new HashSet<String>();
@@ -405,12 +408,18 @@ public class SyncreplConfiguration imple
}
+ /**
+ * @return The ALiasDerefMode parameter
+ */
public AliasDerefMode getAliasDerefMode()
{
return aliasDerefMode;
}
+ /**
+ * @param aliasDerefMode Should be either NEVER_DEREF_ALIASES or DEREF_FINDING_BASE_OBJ
+ */
public void setAliasDerefMode( AliasDerefMode aliasDerefMode )
{
if ( aliasDerefMode != AliasDerefMode.NEVER_DEREF_ALIASES
@@ -424,12 +433,18 @@ public class SyncreplConfiguration imple
}
+ /**
+ * @return The replication cookie
+ */
public byte[] getCookie()
{
return cookie;
}
+ /**
+ * @param cookie The cookie to set
+ */
public void setCookie( byte[] cookie )
{
this.cookie = cookie;
@@ -447,12 +462,19 @@ public class SyncreplConfiguration imple
}
+ /**
+ * Tells if we chase referrals
+ * @return true if we chase referals
+ */
public boolean isChaseReferrals()
{
return chaseReferrals;
}
+ /**
+ * @param chaseReferrals Lust be false, always.
+ */
public void setChaseReferrals( boolean chaseReferrals )
{
if ( chaseReferrals )
@@ -464,12 +486,18 @@ public class SyncreplConfiguration imple
}
+ /**
+ * @return The DN of the configuration entry
+ */
public Dn getConfigEntryDn()
{
return configEntryDn;
}
+ /**
+ * @return true if we use TLS
+ */
public boolean isUseTls()
{
return useTls;
@@ -487,6 +515,9 @@ public class SyncreplConfiguration imple
}
+ /**
+ * @return true if the certificate verification is enforced
+ */
public boolean isStrictCertVerification()
{
return strictCertVerification;
@@ -513,6 +544,9 @@ public class SyncreplConfiguration imple
}
+ /**
+ * @return The Trustmanager instance
+ */
public X509TrustManager getTrustManager()
{
return trustManager;