directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r925326 [4/4] - in /directory/sandbox/seelmann/hbase-partition-test: ./ src/ src/main/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/directory/ src/test/java/org/apache/directory/server/ src/...
Date Fri, 19 Mar 2010 16:59:01 GMT
Added: 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=925326&view=auto
==============================================================================
--- directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java
(added)
+++ directory/sandbox/seelmann/hbase-partition-test/src/test/java/org/apache/directory/server/core/partition/hbase/table/HBasePresenceIndexTableTest.java
Fri Mar 19 16:59:00 2010
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.partition.hbase.table;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.NavigableMap;
+import java.util.UUID;
+
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Tests for {@link HBaseIndexTableBase}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HBasePresenceIndexTableTest extends AbstractHBaseTableTest
+{
+    private static final String OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME = TABLE_PREFIX + "index_objectClass";
+    private static final String JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME = TABLE_PREFIX + "index_jpegPhoto";
+    private HBasePresenceIndexTable objectClassPresenceIndexTable;
+    private HBasePresenceIndexTable jpegPhotoPresenceIndexTable;
+
+
+    /**
+     * Cleanup HBase tables before each test.
+     * 
+     */
+    @Before
+    public void setup() throws Exception
+    {
+        HBaseAdmin admin = new HBaseAdmin( adapter.getHBaseConfigurtion() );
+        if ( admin.tableExists( OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME ) )
+        {
+            HTable objectClassIndexHTable = new HTable( OBJECTCLASS_PRESENCE_INDEX_TABLE_NAME
);
+            ResultScanner treeScanner = objectClassIndexHTable.getScanner( new Scan() );
+            Result treeResult;
+            while ( ( treeResult = treeScanner.next() ) != null )
+            {
+                objectClassIndexHTable.delete( new Delete( treeResult.getRow() ) );
+            }
+        }
+        if ( admin.tableExists( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME ) )
+        {
+            HTable objectClassIndexHTable = new HTable( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME
);
+            ResultScanner treeScanner = objectClassIndexHTable.getScanner( new Scan() );
+            Result treeResult;
+            while ( ( treeResult = treeScanner.next() ) != null )
+            {
+                objectClassIndexHTable.delete( new Delete( treeResult.getRow() ) );
+            }
+        }
+
+        objectClassPresenceIndexTable = new HBasePresenceIndexTable( "2.5.4.0", store, 100
);
+        jpegPhotoPresenceIndexTable = new HBasePresenceIndexTable( "0.9.2342.19200300.100.1.60",
store, 100 );
+    }
+
+
+    @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
);
+
+        Get presenceGet = new Get( Bytes.add( Bytes.toBytes( "*" ), Bytes.toBytes( CONTEXT_ENTRY_ID.toString()
) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( presenceGet ) );
+        Result presenceResult = objectClassPresenceIndexHTable.get( presenceGet );
+
+        NavigableMap<byte[], byte[]> presenceInfoMap = presenceResult.getFamilyMap(
Bytes.toBytes( "info" ) );
+        assertNotNull( presenceInfoMap );
+        assertEquals( 1, presenceInfoMap.size() );
+        assertEquals( "e", Bytes.toString( presenceInfoMap.get( Bytes.toBytes( "status" )
) ) );
+
+        // 2nd entry
+        objectClassPresenceIndexTable.add( OU_SALES_ID );
+
+        // 3rd entry
+        objectClassPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID );
+        jpegPhotoPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID );
+
+        HTable jpegPhotoPresenceIndexHTable = new HTable( JPEGPHOTO_PRESENCE_INDEX_TABLE_NAME
);
+
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CONTEXT_ENTRY_ID.toString() ) ) ) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( OU_SALES_ID.toString() ) ) ) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CN_JOHNNY_WALKER_UUID.toString() ) ) ) ) );
+        assertTrue( jpegPhotoPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CN_JOHNNY_WALKER_UUID.toString() ) ) ) ) );
+    }
+
+
+    @Test
+    public void testDelete() throws Exception
+    {
+        // 1st entry
+        objectClassPresenceIndexTable.add( CONTEXT_ENTRY_ID );
+        // 2nd entry
+        objectClassPresenceIndexTable.add( OU_SALES_ID );
+        // 3rd entry
+        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
);
+
+        // detete 3rd entry
+        objectClassPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID );
+        jpegPhotoPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID );
+
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CONTEXT_ENTRY_ID.toString() ) ) ) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( OU_SALES_ID.toString() ) ) ) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CN_JOHNNY_WALKER_UUID.toString() ) ) ) ) );
+        assertTrue( jpegPhotoPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CN_JOHNNY_WALKER_UUID.toString() ) ) ) ) );
+
+        // detete 2nd and 1st entry
+        objectClassPresenceIndexTable.drop( OU_SALES_ID );
+        objectClassPresenceIndexTable.drop( CONTEXT_ENTRY_ID );
+
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CONTEXT_ENTRY_ID.toString() ) ) ) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( OU_SALES_ID.toString() ) ) ) ) );
+        assertTrue( objectClassPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CN_JOHNNY_WALKER_UUID.toString() ) ) ) ) );
+        assertTrue( jpegPhotoPresenceIndexHTable.exists( new Get( Bytes.add( Bytes.toBytes(
"*" ), Bytes
+            .toBytes( CN_JOHNNY_WALKER_UUID.toString() ) ) ) ) );
+    }
+
+
+    @Test
+    public void testCounts() throws Exception
+    {
+        assertEquals( 0, objectClassPresenceIndexTable.count() );
+
+        // 1st entry
+        objectClassPresenceIndexTable.add( CONTEXT_ENTRY_ID );
+
+        assertEquals( 1, objectClassPresenceIndexTable.count() );
+
+        // 2nd entry
+        objectClassPresenceIndexTable.add( OU_SALES_ID );
+
+        assertEquals( 2, objectClassPresenceIndexTable.count() );
+
+        // 3rd entry
+        objectClassPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID );
+        jpegPhotoPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID );
+
+        assertEquals( 3, objectClassPresenceIndexTable.count() );
+        assertEquals( 1, jpegPhotoPresenceIndexTable.count() );
+
+        // delete 3rd and 2nd
+        objectClassPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID );
+        jpegPhotoPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID );
+        objectClassPresenceIndexTable.drop( OU_SALES_ID );
+
+        assertEquals( 1, objectClassPresenceIndexTable.count() );
+        assertEquals( 0, jpegPhotoPresenceIndexTable.count() );
+
+        // delete 1st
+        objectClassPresenceIndexTable.drop( CONTEXT_ENTRY_ID );
+
+        assertEquals( 0, objectClassPresenceIndexTable.count() );
+    }
+
+
+    @Test
+    public void testExists() throws Exception
+    {
+        assertFalse( objectClassPresenceIndexTable.exists( CONTEXT_ENTRY_ID ) );
+        assertFalse( objectClassPresenceIndexTable.exists( OU_SALES_ID ) );
+        assertFalse( objectClassPresenceIndexTable.exists( CN_JOHNNY_WALKER_UUID ) );
+        assertFalse( jpegPhotoPresenceIndexTable.exists( CN_JOHNNY_WALKER_UUID ) );
+
+        // 1st entry
+        objectClassPresenceIndexTable.add( CONTEXT_ENTRY_ID );
+
+        assertTrue( objectClassPresenceIndexTable.exists( CONTEXT_ENTRY_ID ) );
+
+        // 2nd entry
+        objectClassPresenceIndexTable.add( OU_SALES_ID );
+
+        assertTrue( objectClassPresenceIndexTable.exists( OU_SALES_ID ) );
+
+        // 3rd entry
+        objectClassPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID );
+        jpegPhotoPresenceIndexTable.add( CN_JOHNNY_WALKER_UUID );
+        assertTrue( objectClassPresenceIndexTable.exists( CN_JOHNNY_WALKER_UUID ) );
+        assertTrue( jpegPhotoPresenceIndexTable.exists( CN_JOHNNY_WALKER_UUID ) );
+
+        // delete 3rd and 2nd
+        objectClassPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID );
+        jpegPhotoPresenceIndexTable.drop( CN_JOHNNY_WALKER_UUID );
+        objectClassPresenceIndexTable.drop( OU_SALES_ID );
+
+        assertTrue( objectClassPresenceIndexTable.exists( CONTEXT_ENTRY_ID ) );
+        assertFalse( objectClassPresenceIndexTable.exists( OU_SALES_ID ) );
+        assertFalse( objectClassPresenceIndexTable.exists( CN_JOHNNY_WALKER_UUID ) );
+        assertFalse( jpegPhotoPresenceIndexTable.exists( CONTEXT_ENTRY_ID ) );
+
+        // delete 1st
+        objectClassPresenceIndexTable.drop( CONTEXT_ENTRY_ID );
+
+        assertFalse( objectClassPresenceIndexTable.exists( CONTEXT_ENTRY_ID ) );
+    }
+
+
+    @Test
+    public void testGetPresenceKey() throws Exception
+    {
+        byte[] scanKey = objectClassPresenceIndexTable.getPresenceKey( UUID
+            .fromString( "00000000-0000-0000-0000-000000000000" ) );
+        assertEquals( "*00000000-0000-0000-0000-000000000000", Bytes.toString( scanKey )
);
+
+        UUID uuid = UUID.randomUUID();
+        scanKey = objectClassPresenceIndexTable.getPresenceKey( uuid );
+        assertEquals( "*" + uuid.toString(), Bytes.toString( scanKey ) );
+
+        scanKey = objectClassPresenceIndexTable.getPresenceKey( null );
+        assertEquals( "*", Bytes.toString( scanKey ) );
+
+        scanKey = objectClassPresenceIndexTable.getPresenceKey( HBasePresenceIndexTable.VALUE_SCAN_FIRST_ENTRYID
);
+        assertEquals( "*00000000-0000-0000-0000-000000000000", Bytes.toString( scanKey )
);
+
+        scanKey = objectClassPresenceIndexTable.getPresenceKey( HBasePresenceIndexTable.VALUE_SCAN_LAST_ENTRYID
);
+        assertEquals( "*ffffffff-ffff-ffff-ffff-ffffffffffff", Bytes.toString( scanKey )
);
+    }
+
+
+    @Test
+    public void testExtractGetPresenceKey() throws Exception
+    {
+        UUID uuid = objectClassPresenceIndexTable.extractEntryIdFromPresenceKey( Bytes
+            .toBytes( "*00000000-0000-0000-0000-000000000000" ) );
+        assertEquals( "00000000-0000-0000-0000-000000000000", uuid.toString() );
+    }
+
+
+    @Test
+    public void last() throws Exception
+    {
+    }
+
+}

Added: directory/sandbox/seelmann/hbase-partition-test/src/test/resources/hbase-site.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition-test/src/test/resources/hbase-site.xml?rev=925326&view=auto
==============================================================================
--- directory/sandbox/seelmann/hbase-partition-test/src/test/resources/hbase-site.xml (added)
+++ directory/sandbox/seelmann/hbase-partition-test/src/test/resources/hbase-site.xml Fri
Mar 19 16:59:00 2010
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<configuration>
+<!-- 
+  <property>
+    <name>hbase.zookeeper.quorum</name>
+    <value>hadoop2,hadoop3,hadoop4</value>
+  </property>
+  
+  <property>
+    <name>mapred.job.tracker</name>
+    <value>hadoop1:9001</value>
+  </property>
+  
+  <property>
+    <name>org.apache.directory.compression.algorithm</name>
+    <value>LZO</value>
+  </property>
+ -->
+  
+</configuration>

Added: 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=925326&view=auto
==============================================================================
--- directory/sandbox/seelmann/hbase-partition-test/src/test/resources/log4j.properties (added)
+++ directory/sandbox/seelmann/hbase-partition-test/src/test/resources/log4j.properties Fri
Mar 19 16:59:00 2010
@@ -0,0 +1,51 @@
+#############################################################################
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#############################################################################
+log4j.rootCategory=ERROR, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+#log4j.appender.R=org.apache.log4j.RollingFileAppender
+#log4j.appender.R.File=apacheds-rolling.log
+#
+#log4j.appender.R.MaxFileSize=1024KB
+## Keep some backup files
+#log4j.appender.R.MaxBackupIndex=5
+#
+#log4j.appender.R.layout=org.apache.log4j.PatternLayout
+#log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss:SSS}] %p [%c{1}] - %m%n
+
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss:SSS}] %p [%c{1}] - %m%n
+
+# with these we'll not get innundated when switching to DEBUG
+#log4j.logger.org.apache.directory.server.kerberos=DEBUG
+#log4j.logger.org.apache.directory.server.changepw=DEBUG
+#log4j.logger.org.apache.directory.server.ldap.handlers=DEBUG
+log4j.logger.org.apache.directory.shared.ldap.name=WARN
+log4j.logger.org.springframework=WARN
+log4j.logger.org.apache.directory.shared.codec=WARN
+log4j.logger.org.apache.directory.shared.asn1=WARN
+
+log4j.logger.org.apache.directory.server.schema.registries=WARN
+
+#log4j.logger.org.apache.directory.server.core.partition.hbase.table.HBaseTableHelper=DEBUG
+#log4j.logger.org.apache.directory.server.core.partition.hbase.table=TRACE
+#log4j.logger.org.apache.directory.server.core.partition.hbase.table.HBaseMasterTable$MasterTableKey=DEBUG
+#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

Added: directory/sandbox/seelmann/hbase-partition-test/src/test/resources/mapred-site.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition-test/src/test/resources/mapred-site.xml?rev=925326&view=auto
==============================================================================
--- directory/sandbox/seelmann/hbase-partition-test/src/test/resources/mapred-site.xml (added)
+++ directory/sandbox/seelmann/hbase-partition-test/src/test/resources/mapred-site.xml Fri
Mar 19 16:59:00 2010
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<configuration>
+<!-- 
+  <property>
+    <name>fs.default.name</name>
+    <value>hdfs://hadoop1:9000</value>
+  </property>
+
+  <property>
+    <name>mapred.job.tracker</name>
+    <value>hadoop1:9001</value>
+  </property>
+  
+  <property>
+    <name>org.apache.directory.compression.algorithm</name>
+    <value>LZO</value>
+  </property>  
+ -->
+  
+</configuration>

Added: directory/sandbox/seelmann/hbase-partition-test/src/test/resources/testdata-5.ldif
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/hbase-partition-test/src/test/resources/testdata-5.ldif?rev=925326&view=auto
==============================================================================
--- directory/sandbox/seelmann/hbase-partition-test/src/test/resources/testdata-5.ldif (added)
+++ directory/sandbox/seelmann/hbase-partition-test/src/test/resources/testdata-5.ldif Fri
Mar 19 16:59:00 2010
@@ -0,0 +1,40 @@
+
+
+
+dn: uid=hnelson,ou=users,dc=example,dc=com
+objectClass: inetOrgPerson
+objectClass: organizationalPerson
+objectClass: person
+objectClass: top
+uid: hnelson
+sn: Nelson
+givenName: Horation
+cn: Horation Nelson
+
+
+
+dn: dc=example,dc=com
+objectClass: domain
+objectClass: top
+dc: example
+
+dn: ou=groups,dc=example,dc=com
+objectClass: organizationalUnit
+objectClass: top
+ou: groups
+
+dn: uid=hhornblo,ou=users,dc=example,dc=com
+objectClass: inetOrgPerson
+objectClass: organizationalPerson
+objectClass: person
+objectClass: top
+uid: hhornblo
+sn: Hornblower
+givenName: Horation
+cn: Horatio Hornblower
+
+
+dn: ou=users,dc=example,dc=com
+objectClass: organizationalUnit
+objectClass: top
+ou: users



Mime
View raw message