directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1227407 - in /directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit: DataChangeContainer.java EntryAddDelete.java IndexChange.java
Date Thu, 05 Jan 2012 00:08:25 GMT
Author: elecharny
Date: Thu Jan  5 00:08:24 2012
New Revision: 1227407

URL: http://svn.apache.org/viewvc?rev=1227407&view=rev
Log:
Added toString() methods

Modified:
    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryAddDelete.java
    directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java?rev=1227407&r1=1227406&r2=1227407&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/DataChangeContainer.java
Thu Jan  5 00:08:24 2012
@@ -23,16 +23,12 @@ package org.apache.directory.server.core
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import java.util.Comparator;
-import java.util.List;
-import java.util.LinkedList;
 import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.UUID;
 
-import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.name.Dn;
-
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.partition.index.MasterTable;
 import org.apache.directory.server.core.api.partition.index.UUIDComparator;
@@ -40,6 +36,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.txn.logedit.DataChange;
 import org.apache.directory.server.core.api.txn.logedit.EntryModification;
 import org.apache.directory.server.core.api.txn.logedit.IndexModification;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.name.Dn;
 
 
 /**
@@ -58,7 +56,7 @@ public class DataChangeContainer extends
 
     /** Partition stored for fast access */
     private transient Partition partition;
-    
+
     /** partition this change applies to */
     private Dn partitionDn;
 
@@ -79,11 +77,13 @@ public class DataChangeContainer extends
         this.partition = partition;
     }
 
+
     public DataChangeContainer( Dn partitionDn )
     {
         this.partitionDn = partitionDn;
     }
 
+
     public long getTxnID()
     {
         return txnID;
@@ -100,7 +100,8 @@ public class DataChangeContainer extends
     {
         return partitionDn;
     }
-    
+
+
     public Partition getPartition()
     {
         return partition;
@@ -250,7 +251,7 @@ public class DataChangeContainer extends
                         needToCloneOnChange = false;
                     }
 
-                   curEntry = entryModification.applyModification( partition, curEntry, id,
changeLsn, true );
+                    curEntry = entryModification.applyModification( partition, curEntry,
id, changeLsn, true );
                 }
             }
 
@@ -263,9 +264,9 @@ public class DataChangeContainer extends
     @Override
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
-        
+
         boolean hasID = in.readBoolean();
-        
+
         if ( hasID )
         {
             entryID = UUID.fromString( in.readUTF() );
@@ -274,7 +275,7 @@ public class DataChangeContainer extends
         {
             entryID = null;
         }
-        
+
         txnID = in.readLong();
 
         partitionDn = new Dn();
@@ -295,7 +296,7 @@ public class DataChangeContainer extends
     public void writeExternal( ObjectOutput out ) throws IOException
     {
         DataChange change;
-        
+
         if ( entryID != null )
         {
             out.writeBoolean( true );
@@ -305,7 +306,7 @@ public class DataChangeContainer extends
         {
             out.writeBoolean( false );
         }
-        
+
         out.writeLong( txnID );
 
         partitionDn.writeExternal( out );

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryAddDelete.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryAddDelete.java?rev=1227407&r1=1227406&r2=1227407&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryAddDelete.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/EntryAddDelete.java
Thu Jan  5 00:08:24 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.shared.txn.logedit;
 
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -27,8 +28,9 @@ import java.util.UUID;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.txn.logedit.AbstractDataChange;
 import org.apache.directory.server.core.api.txn.logedit.EntryModification;
-import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+
 
 /**
  * 
@@ -38,35 +40,37 @@ public class EntryAddDelete extends Abst
 {
     /** Added or deleted entry */
     private Entry entry;
-    
+
     /** Type of change */
     Type type;
-    
+
+
     // For externalizable
-    public EntryAddDelete(  )
+    public EntryAddDelete()
     {
-        
+
     }
-    
+
+
     public EntryAddDelete( Entry entry, Type type )
     {
         this.entry = entry;
         this.type = type;
     }
-    
-    
+
+
     public Entry getChangedEntry()
     {
         return entry;
     }
-    
-    
+
+
     public Type getType()
     {
         return type;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -110,27 +114,47 @@ public class EntryAddDelete extends Abst
 
         return curEntry;
     }
-    
-    
+
+
     @Override
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
-     entry = new DefaultEntry();
-     entry.readExternal( in );
-     type = Type.values()[in.readInt()];
+        entry = new DefaultEntry();
+        entry.readExternal( in );
+        type = Type.values()[in.readInt()];
     }
 
 
     @Override
     public void writeExternal( ObjectOutput out ) throws IOException
     {
-       entry.writeExternal( out );
-       out.writeInt( type.ordinal() );
+        entry.writeExternal( out );
+        out.writeInt( type.ordinal() );
     }
-    
+
     public enum Type
     {
         ADD,
         DELETE
     }
+
+
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "EntryAddDelete change : " );
+        sb.append( type );
+
+        if ( type == Type.ADD )
+        {
+            sb.append( '\n' ).append( entry );
+        }
+        else
+        {
+            sb.append( entry.getDn() );
+        }
+
+        return sb.toString();
+    }
 }

Modified: directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java?rev=1227407&r1=1227406&r2=1227407&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-shared/src/main/java/org/apache/directory/server/core/shared/txn/logedit/IndexChange.java
Thu Jan  5 00:08:24 2012
@@ -55,6 +55,7 @@ public class IndexChange extends Abstrac
     /** Whether the index is a system index. False is user index */
     private boolean isSystemIndex;
 
+
     // For externalizable
     public IndexChange()
     {
@@ -101,25 +102,26 @@ public class IndexChange extends Abstrac
         return type;
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     public void applyModification( Partition partition, boolean recovery ) throws Exception
     {
-        Index<Object> index = ( Index<Object> )partition.getIndex( oid );
-        
+        Index<Object> index = ( Index<Object> ) partition.getIndex( oid );
+
         if ( index == null )
         {
             // TODO decide how to handle index add drop
         }
-        
+
         if ( type == Type.ADD )
         {
             // During recovery, idex might have already been added. But it should not hurt
to readd the index entry.
             index.add( key, id );
         }
-        else // delete
+        else
+        // delete
         {
             if ( recovery == false )
             {
@@ -130,12 +132,12 @@ public class IndexChange extends Abstrac
                 //If forward or reverse index entry existence diffes, first add the index
entry and then delete it.
                 boolean forwardExists = index.forward( key, id );
                 boolean reverseExists = index.reverse( id, key );
-                
+
                 if ( forwardExists != reverseExists )
                 {
                     // We assume readding the same entry to an index wont hurt
                     index.add( key, id );
-                    
+
                     index.drop( key, id );
                 }
                 else if ( forwardExists )
@@ -146,8 +148,8 @@ public class IndexChange extends Abstrac
             }
         }
     }
-    
-    
+
+
     @Override
     @SuppressWarnings("unchecked")
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
@@ -173,4 +175,27 @@ public class IndexChange extends Abstrac
         ADD,
         DELETE
     }
+
+
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "IndexChange '" );
+        // The index's name
+        sb.append( index.getAttribute().getName() ).append( "': " );
+
+        // The change' type
+        sb.append( "<" ).append( type ).append( ", " );
+
+        // The entry's UUID
+        sb.append( id ).append( ", " );
+
+        // The key
+        sb.append( key );
+
+        sb.append( ">" );
+
+        return sb.toString();
+    }
 }



Mime
View raw message