Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 60038 invoked from network); 5 Nov 2010 22:17:46 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Nov 2010 22:17:46 -0000 Received: (qmail 49985 invoked by uid 500); 5 Nov 2010 22:18:17 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 49940 invoked by uid 500); 5 Nov 2010 22:18:17 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 49933 invoked by uid 99); 5 Nov 2010 22:18:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Nov 2010 22:18:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Nov 2010 22:18:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C3C6023889DA; Fri, 5 Nov 2010 22:17:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1031855 [2/2] - in /directory/sandbox/seelmann/hbase-partition-test: ./ src/test/java/org/apache/directory/server/core/partition/hbase/ src/test/java/org/apache/directory/server/core/partition/hbase/it/ src/test/java/org/apache/directory/s... Date: Fri, 05 Nov 2010 22:17:02 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101105221702.C3C6023889DA@eris.apache.org> Modified: directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTableTest.java URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTableTest.java?rev=1031855&r1=1031854&r2=1031855&view=diff ============================================================================== --- directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTableTest.java (original) +++ directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBaseMasterTableTest.java Fri Nov 5 22:17:01 2010 @@ -20,17 +20,17 @@ package org.apache.directory.server.core import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.File; import java.util.NavigableMap; import java.util.UUID; -import org.apache.directory.server.core.entry.DefaultServerEntry; import org.apache.directory.server.core.partition.hbase.HBaseStore; import org.apache.directory.server.core.partition.hbase.Utils; +import org.apache.directory.shared.ldap.entry.Entry; import org.apache.directory.shared.ldap.name.DN; import org.apache.directory.shared.ldap.name.RDN; import org.apache.hadoop.hbase.client.Delete; @@ -56,6 +56,7 @@ public class HBaseMasterTableTest extend private static final String MASTER_TABLE_NAME = TABLE_PREFIX + "master"; private static final String TREE_TABLE_NAME = TABLE_PREFIX + "tree"; + private HBaseStore store; private HBaseMasterTable masterTable; @@ -66,10 +67,18 @@ public class HBaseMasterTableTest extend @Before public void setup() throws Exception { - HBaseAdmin admin = new HBaseAdmin( adapter.getHBaseConfigurtion() ); + store = new HBaseStore(); + store.setPartitionDir( new File( workingDirectory, "store" ) ); + store.setSuffixDn( suffixDn ); + store.setCacheSize( 100 ); + store.setTablePrefix( TABLE_PREFIX ); + store.init( schemaManager ); + masterTable = store.getMasterTable(); + + HBaseAdmin admin = new HBaseAdmin( store.getConfiguration() ); if ( admin.tableExists( MASTER_TABLE_NAME ) ) { - HTable masterHTable = new HTable( MASTER_TABLE_NAME ); + HTable masterHTable = new HTable( store.getConfiguration(), MASTER_TABLE_NAME ); ResultScanner masterScanner = masterHTable.getScanner( new Scan() ); Result masterResult; while ( ( masterResult = masterScanner.next() ) != null ) @@ -79,7 +88,7 @@ public class HBaseMasterTableTest extend } if ( admin.tableExists( TREE_TABLE_NAME ) ) { - HTable treeHTable = new HTable( TREE_TABLE_NAME ); + HTable treeHTable = new HTable( store.getConfiguration(), TREE_TABLE_NAME ); ResultScanner treeScanner = treeHTable.getScanner( new Scan() ); Result treeResult; while ( ( treeResult = treeScanner.next() ) != null ) @@ -87,22 +96,6 @@ public class HBaseMasterTableTest extend treeHTable.delete( new Delete( treeResult.getRow() ) ); } } - - HBaseStore store = new HBaseStore(); - store.setSuffixDn( suffixDn.getName() ); - store.setCacheSize( 100 ); - store.setTablePrefix( TABLE_PREFIX ); - store.init( schemaManager ); - - masterTable = new HBaseMasterTable( store ); - } - - - @Test - public void first() throws Exception - { - DefaultServerEntry entry = buildContextEntry(); - masterTable.add( entry ); } @@ -117,11 +110,11 @@ public class HBaseMasterTableTest extend public void testAdd() throws Exception { // add context entry - DefaultServerEntry entry = buildContextEntry(); + Entry entry = buildContextEntry(); masterTable.add( entry ); - HTable masterHTable = new HTable( MASTER_TABLE_NAME ); - HTable treeHTable = new HTable( TREE_TABLE_NAME ); + HTable masterHTable = new HTable( store.getConfiguration(), MASTER_TABLE_NAME ); + HTable treeHTable = new HTable( store.getConfiguration(), TREE_TABLE_NAME ); // check state in HBase table 'master' Get masterGet = new Get( Bytes.toBytes( CONTEXT_ENTRY_ID.toString() ) ); @@ -196,15 +189,15 @@ public class HBaseMasterTableTest extend public void testDelete() throws Exception { // add context entry - DefaultServerEntry entry = buildContextEntry(); + Entry entry = buildContextEntry(); masterTable.add( entry ); // add second entry entry = buildOuSalesEntry(); masterTable.add( entry ); - HTable masterHTable = new HTable( MASTER_TABLE_NAME ); - HTable treeHTable = new HTable( TREE_TABLE_NAME ); + HTable masterHTable = new HTable( store.getConfiguration(), MASTER_TABLE_NAME ); + HTable treeHTable = new HTable( store.getConfiguration(), TREE_TABLE_NAME ); // delete second entry masterTable.delete( OU_SALES_ID, entry ); @@ -219,8 +212,9 @@ public class HBaseMasterTableTest extend masterTable.delete( CONTEXT_ENTRY_ID, entry ); masterGet = new Get( Bytes.toBytes( CONTEXT_ENTRY_ID.toString() ) ); assertTrue( masterHTable.exists( masterGet ) ); - treeGet = new Get( Bytes.add( Bytes.toBytes( "00000000-0000-0000-0000-000000000000" ), Bytes.toBytes( "," ), Bytes - .toBytes( "2.5.4.10=good times co." ) ) ); + treeGet = new Get( Bytes.add( Bytes.toBytes( "00000000-0000-0000-0000-000000000000" ), Bytes.toBytes( "," ), + Bytes + .toBytes( "2.5.4.10=good times co." ) ) ); assertTrue( treeHTable.exists( treeGet ) ); } @@ -229,17 +223,18 @@ public class HBaseMasterTableTest extend public void testModify() throws Exception { // add context entry - DefaultServerEntry entry = buildContextEntry(); + Entry entry = buildContextEntry(); masterTable.add( entry ); // modify some attributes entry.get( "objectClass" ).add( "top" ); entry.removeAttributes( "postalCode" ); - entry.get( "postOfficeBox" ).put( "2" ); + entry.get( "postOfficeBox" ).clear(); + entry.get( "postOfficeBox" ).add( "2" ); masterTable.modify( CONTEXT_ENTRY_ID, entry ); // check state in HBase table 'master' - HTable masterHTable = new HTable( MASTER_TABLE_NAME ); + HTable masterHTable = new HTable( store.getConfiguration(), MASTER_TABLE_NAME ); Get masterGet = new Get( Bytes.toBytes( CONTEXT_ENTRY_ID.toString() ) ); assertTrue( masterHTable.exists( masterGet ) ); Result masterResult = masterHTable.get( masterGet ); @@ -274,25 +269,25 @@ public class HBaseMasterTableTest extend .toBytes( "entryCsn" ), Bytes.toBytes( 0 ) ) ) ) ); } - + @Test public void testRename() throws Exception { // add context entry - DefaultServerEntry entry = buildContextEntry(); + Entry entry = buildContextEntry(); masterTable.add( entry ); // add second entry entry = buildOuSalesEntry(); masterTable.add( entry ); - + // rename - RDN rdn = new RDN("ou=SaLeS-US"); + RDN rdn = new RDN( "ou=SaLeS-US" ); rdn.normalize( schemaManager.getNormalizerMapping() ); masterTable.move( OU_SALES_ID, null, rdn ); - - HTable masterHTable = new HTable( MASTER_TABLE_NAME ); - HTable treeHTable = new HTable( TREE_TABLE_NAME ); + + HTable masterHTable = new HTable( store.getConfiguration(), MASTER_TABLE_NAME ); + HTable treeHTable = new HTable( store.getConfiguration(), TREE_TABLE_NAME ); // check in HBase tables Get masterGet = new Get( Bytes.toBytes( OU_SALES_ID.toString() ) ); @@ -300,12 +295,12 @@ public class HBaseMasterTableTest extend Get treeGet = new Get( Bytes.add( Bytes.toBytes( CONTEXT_ENTRY_ID.toString() ), Bytes.toBytes( "," ), Bytes .toBytes( "2.5.4.11=sales-us" ) ) ); assertTrue( treeHTable.exists( treeGet ) ); - } - + + private void dump() throws Exception { - HTable masterHTable = new HTable( MASTER_TABLE_NAME ); + HTable masterHTable = new HTable( store.getConfiguration(), MASTER_TABLE_NAME ); ResultScanner masterScanner = masterHTable.getScanner( new Scan() ); Result masterResult; while ( ( masterResult = masterScanner.next() ) != null ) @@ -313,7 +308,7 @@ public class HBaseMasterTableTest extend System.out.println( "master: " + Utils.getPrintableString( masterResult.getRow() ) ); } - HTable treeHTable = new HTable( TREE_TABLE_NAME ); + HTable treeHTable = new HTable( store.getConfiguration(), TREE_TABLE_NAME ); ResultScanner treeScanner = treeHTable.getScanner( new Scan() ); Result treeResult; while ( ( treeResult = treeScanner.next() ) != null ) @@ -322,11 +317,12 @@ public class HBaseMasterTableTest extend } } + @Test public void testFetch() throws Exception { // add first entry - DefaultServerEntry contextEntry = buildContextEntry(); + Entry contextEntry = buildContextEntry(); masterTable.add( contextEntry ); // fetch norm attributes @@ -354,7 +350,7 @@ public class HBaseMasterTableTest extend public void testFetchId() throws Exception { // add first entry - DefaultServerEntry contextEntry = buildContextEntry(); + Entry contextEntry = buildContextEntry(); masterTable.add( contextEntry ); // fetch ID @@ -364,7 +360,7 @@ public class HBaseMasterTableTest extend assertEquals( 1, count2 - count1 ); // add second entry - DefaultServerEntry ouSalesEntry = buildOuSalesEntry(); + Entry ouSalesEntry = buildOuSalesEntry(); masterTable.add( ouSalesEntry ); // fetch entry ID @@ -385,7 +381,7 @@ public class HBaseMasterTableTest extend assertNull( masterTable.fetchId( ouSalesEntry.getDn() ) ); // fetch entry IDs of non-existing entries - assertNull( masterTable.fetchId( null ) ); + assertNull( masterTable.fetchId( ( DN ) null ) ); assertNull( masterTable.fetchId( new DN( "a=b" ) ) ); } @@ -394,7 +390,7 @@ public class HBaseMasterTableTest extend public void testFetchParentId() throws Exception { // add first entry - DefaultServerEntry contextEntry = buildContextEntry(); + Entry contextEntry = buildContextEntry(); masterTable.add( contextEntry ); // fetch parent ID @@ -404,7 +400,7 @@ public class HBaseMasterTableTest extend assertEquals( 1, count2 - count1 ); // add second entry - DefaultServerEntry ouSalesEntry = buildOuSalesEntry(); + Entry ouSalesEntry = buildOuSalesEntry(); masterTable.add( ouSalesEntry ); // fetch parent ID @@ -435,7 +431,7 @@ public class HBaseMasterTableTest extend public void testFetchEntry() throws Exception { // add first entry - DefaultServerEntry contextEntry = buildContextEntry(); + Entry contextEntry = buildContextEntry(); masterTable.add( contextEntry ); // fetch first entry @@ -447,7 +443,7 @@ public class HBaseMasterTableTest extend assertEquals( 1, count2 - count1 ); // add second entry - DefaultServerEntry ouSalesEntry = buildOuSalesEntry(); + Entry ouSalesEntry = buildOuSalesEntry(); masterTable.add( ouSalesEntry ); // fetch second entry @@ -483,7 +479,7 @@ public class HBaseMasterTableTest extend public void testOneAndSubLevelCount() throws Exception { // add context entry - DefaultServerEntry contextEntry = buildContextEntry(); + Entry contextEntry = buildContextEntry(); masterTable.add( contextEntry ); // check counters @@ -491,7 +487,7 @@ public class HBaseMasterTableTest extend assertEquals( 0, masterTable.getSubLevelCount( CONTEXT_ENTRY_ID ) ); // add ou=Sales entry - DefaultServerEntry ouSalesEntry = buildOuSalesEntry(); + Entry ouSalesEntry = buildOuSalesEntry(); masterTable.add( ouSalesEntry ); // check counters @@ -503,7 +499,7 @@ public class HBaseMasterTableTest extend assertEquals( 1, masterTable.getSubLevelCount( CONTEXT_ENTRY_ID ) ); // add cn=Jonny Walker entry - DefaultServerEntry cnJohnnyWalkerEntry = buildCnJohnnyWalkerEntry(); + Entry cnJohnnyWalkerEntry = buildCnJohnnyWalkerEntry(); masterTable.add( cnJohnnyWalkerEntry ); // check counters @@ -545,10 +541,4 @@ public class HBaseMasterTableTest extend assertEquals( 0, masterTable.getSubLevelCount( UUID.randomUUID() ) ); } - - @Test - public void last() throws Exception - { - } - } Modified: directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java?rev=1031855&r1=1031854&r2=1031855&view=diff ============================================================================== --- directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java (original) +++ directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java Fri Nov 5 22:17:01 2010 @@ -24,9 +24,11 @@ import static org.junit.Assert.assertFal import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.io.File; import java.util.NavigableMap; import java.util.UUID; +import org.apache.directory.server.core.partition.hbase.HBaseStore; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HBaseAdmin; @@ -51,6 +53,7 @@ public class HBasePresenceIndexTableTest private static final String JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME = TABLE_PREFIX + "index_jpegPhoto"; private HBasePresenceIndexTable objectClassPresenceIndexTable; private HBasePresenceIndexTable jpegPhotoPresenceIndexTable; + private HBaseStore store; /** @@ -60,10 +63,17 @@ public class HBasePresenceIndexTableTest @Before public void setup() throws Exception { - HBaseAdmin admin = new HBaseAdmin( adapter.getHBaseConfigurtion() ); + store = new HBaseStore(); + store.setPartitionDir( new File( workingDirectory, "store" ) ); + store.setSuffixDn( suffixDn ); + store.setCacheSize( 100 ); + store.setTablePrefix( TABLE_PREFIX ); + store.init( schemaManager ); + + HBaseAdmin admin = new HBaseAdmin( store.getConfiguration() ); if ( admin.tableExists( OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ) ) { - HTable objectClassIndexHTable = new HTable( OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ); + HTable objectClassIndexHTable = new HTable( store.getConfiguration(), OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ); ResultScanner treeScanner = objectClassIndexHTable.getScanner( new Scan() ); Result treeResult; while ( ( treeResult = treeScanner.next() ) != null ) @@ -73,7 +83,7 @@ public class HBasePresenceIndexTableTest } if ( admin.tableExists( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ) ) { - HTable objectClassIndexHTable = new HTable( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ); + HTable objectClassIndexHTable = new HTable( store.getConfiguration(), JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ); ResultScanner treeScanner = objectClassIndexHTable.getScanner( new Scan() ); Result treeResult; while ( ( treeResult = treeScanner.next() ) != null ) @@ -88,19 +98,13 @@ public class HBasePresenceIndexTableTest @Test - public void first() throws Exception - { - objectClassPresenceIndexTable.add( CONTEXT_ENTRY_ID ); - } - - - @Test public void testAdd() throws Exception { // 1st entry objectClassPresenceIndexTable.add( CONTEXT_ENTRY_ID ); - HTable objectClassPresenceIndexHTable = new HTable( OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ); + HTable objectClassPresenceIndexHTable = new HTable( store.getConfiguration(), + OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ); Get presenceGet = new Get( Bytes.add( Bytes.toBytes( "*" ), Bytes.toBytes( CONTEXT_ENTRY_ID.toString() ) ) ); assertTrue( objectClassPresenceIndexHTable.exists( presenceGet ) ); @@ -118,7 +122,7 @@ public class HBasePresenceIndexTableTest objectClassPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID ); jpegPhotoPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID ); - HTable jpegPhotoPresenceIndexHTable = new HTable( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ); + HTable jpegPhotoPresenceIndexHTable = new HTable( store.getConfiguration(), JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ); assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes( "*" ), Bytes .toBytes( CONTEXT_ENTRY_ID.toString() ) ) ) ) ); @@ -142,8 +146,9 @@ public class HBasePresenceIndexTableTest objectClassPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID ); jpegPhotoPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID ); - HTable objectClassPresenceIndexHTable = new HTable( OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ); - HTable jpegPhotoPresenceIndexHTable = new HTable( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ); + HTable objectClassPresenceIndexHTable = new HTable( store.getConfiguration(), + OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ); + HTable jpegPhotoPresenceIndexHTable = new HTable( store.getConfiguration(), JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ); // detete 3rd entry objectClassPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID ); @@ -281,10 +286,4 @@ public class HBasePresenceIndexTableTest assertEquals( "00000000-0000-0000-0000-000000000000", uuid.toString() ); } - - @Test - public void last() throws Exception - { - } - } Modified: directory/sandbox/seelmann/hbase-partition-test/src/test/resources/log4j.properties URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition-test/src/test/resources/log4j.properties?rev=1031855&r1=1031854&r2=1031855&view=diff ============================================================================== --- directory/sandbox/seelmann/hbase-partition-test/src/test/resources/log4j.properties (original) +++ directory/sandbox/seelmann/hbase-partition-test/src/test/resources/log4j.properties Fri Nov 5 22:17:01 2010 @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################# -log4j.rootCategory=ERROR, stdout +log4j.rootCategory=OFF, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout @@ -48,4 +48,4 @@ log4j.logger.org.apache.directory.server #log4j.logger.org.apache.hadoop.hbase.client=DEBUG log4j.logger.org.apache.hadoop=ERROR log4j.logger.org.apache.hadoop.metrics=FATAL -log4j.logger.org.apache.hadoop.hbase.metrics=FATAL \ No newline at end of file +log4j.logger.org.apache.hadoop.hbase.metrics=FATAL