directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1687672 - in /directory/sandbox/kayyagari/partition-plumber: pom.xml src/main/java/org/apache/directory/PartitionPlumber.java
Date Fri, 26 Jun 2015 03:57:09 GMT
Author: kayyagari
Date: Fri Jun 26 03:57:09 2015
New Revision: 1687672

URL: http://svn.apache.org/r1687672
Log:
o bumped the version of DS
o check for a duplicate entry ID to detect loop

Modified:
    directory/sandbox/kayyagari/partition-plumber/pom.xml
    directory/sandbox/kayyagari/partition-plumber/src/main/java/org/apache/directory/PartitionPlumber.java

Modified: directory/sandbox/kayyagari/partition-plumber/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/partition-plumber/pom.xml?rev=1687672&r1=1687671&r2=1687672&view=diff
==============================================================================
--- directory/sandbox/kayyagari/partition-plumber/pom.xml (original)
+++ directory/sandbox/kayyagari/partition-plumber/pom.xml Fri Jun 26 03:57:09 2015
@@ -10,7 +10,7 @@
 		<dependency>
 			<groupId>org.apache.directory.server</groupId>
 			<artifactId>apacheds-service</artifactId>
-			<version>2.0.0-M18</version>
+			<version>2.0.0-M20</version>
 		</dependency>
 	</dependencies>
 	<build>

Modified: directory/sandbox/kayyagari/partition-plumber/src/main/java/org/apache/directory/PartitionPlumber.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/partition-plumber/src/main/java/org/apache/directory/PartitionPlumber.java?rev=1687672&r1=1687671&r2=1687672&view=diff
==============================================================================
--- directory/sandbox/kayyagari/partition-plumber/src/main/java/org/apache/directory/PartitionPlumber.java
(original)
+++ directory/sandbox/kayyagari/partition-plumber/src/main/java/org/apache/directory/PartitionPlumber.java
Fri Jun 26 03:57:09 2015
@@ -21,6 +21,8 @@ package org.apache.directory;
 
 import java.io.File;
 import java.io.FileWriter;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
@@ -36,7 +38,6 @@ import org.apache.directory.server.Apach
 import org.apache.directory.server.core.api.InstanceLayout;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.partition.PartitionNexus;
-import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmRdnIndex;
 import org.apache.directory.server.xdbm.Index;
@@ -115,10 +116,9 @@ public class PartitionPlumber
         String version = nexus.getRootDseValue( sm.lookupAttributeTypeRegistry( SchemaConstants.VENDOR_VERSION_AT
) )
             .getString();
 
-        if ( !( version.startsWith( "2.0.0-M15" ) || version.startsWith( "2.0.0-M16" )
-            || version.startsWith( "2.0.0-M17" ) || version.startsWith( "2.0.0-M18" ) ) )
+        if ( version.equals( "2.0.0-M14" ) || !version.startsWith( "2.0.0" ) )
         {
-            System.out.println( "This tool can only work on versions 2.0.0-M15 to 2.0.0-M18"
);
+            System.out.println( "This tool can only work on versions >= 2.0.0-M15" );
             return;
         }
 
@@ -277,28 +277,43 @@ public class PartitionPlumber
 
         int count = 0;
 
-        dirPath = dirPath + File.separator + partitionDn + ".ldif";
+        String filePath = dirPath + File.separator + partitionDn + ".ldif";
 
-        System.out.println( "Exporting data of " + partitionDn + " to the file " + dirPath
);
+        System.out.println( "Exporting data of " + partitionDn + " to the file " + filePath
);
 
-        FileWriter fw = new FileWriter( dirPath );
+        FileWriter fw = new FileWriter( filePath );
 
+        Set<String> knownIdSet = new HashSet<String>();
+        
         while ( cursor.next() )
         {
             Tuple<String, Entry> t = cursor.get();
 
             Entry entry = t.getValue();
+            
+            String entryId = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
 
+            if( knownIdSet.contains( entryId ) )
+            {
+                String err = "Found an entry %s that was already read, this is possibly due
to a corrupted master table, stopping exporting of entries from here to avoid duplicates";
+                err = String.format( err, entryId );
+                System.out.println( err );
+                break;
+            }
+            
+            knownIdSet.add( entryId );
+            
             //rdnIdx.
             String ldif = LdifUtils.convertToLdif( entry );
 
-            fw.write( "dn: " + entry.getDn().getName() + "\n" + ldif );
+            fw.write( ldif );
             fw.write( '\n' );
             count++;
         }
 
         fw.close();
         cursor.close();
+        knownIdSet.clear();
 
         System.out.println( "exported " + count + " entries" );
     }



Mime
View raw message