Search code examples
javahadoophbasekundera

Hbase Kundera Table with namespace not working


Using Kundera I wanted to create Tables in Given NameSpace

example

foo:bar 

where foo is namespace & bar is tablename

This is not happening with below configuration

Here is my persistent Unit

    <provider>com.impetus.kundera.KunderaPersistence</provider>

    <properties>
        <property name="kundera.nodes" value="ZookeeperIP" />
        <property name="kundera.port" value="2181" />
        <property name="kundera.client.property" value="User.xml"/>
        <property name="kundera.keyspace" value="UserPROFILE" />
        <property name="kundera.dialect" value="hbase" />
        <property name="kundera.ddl.auto.prepare" value="update" />
        <property name="kundera.client.lookup.class" value="com.impetus.client.hbase.HBaseClientFactory" />
    </properties>
</persistence-unit>

Here is my User.xml

<clientProperties>
    <datastores>
        <dataStore>
            <name>hbase</name>
            <connection>
                <properties>
                    <property name="hbase.zookeeper.quorum" value="ZookeeperIP"/>
                    <property name="hbase.zookeeper.property.clientPort" value="2181"/>
                </properties>
            </connection>
            <schemas>
                <schema>
                    <name>UNIVERCITY</name>
                    <tables>
                        <table>
                            <name>STUDENT</name>
                            <properties>
                                <property name="TTL" value="12345678"/>
                                <property name="VERSIONS" value="6"/>
                                <property name="MIN_VERSIONS" value="3"/>
                                <property name="COMPRESSION" value="GZ"/>
                                <property name="COMPRESSION_COMPACT" value="GZ"/>
                            </properties>
                        </table>

                       <table>
                            <name>COURCES</name>
                            <properties>
                                <property name="TTL" value="12345678"/>
                                <property name="VERSIONS" value="6"/>
                                <property name="MIN_VERSIONS" value="3"/>
                                <property name="COMPRESSION" value="GZ"/>
                                <property name="COMPRESSION_COMPACT" value="GZ"/>
                            </properties>
                        </table>

</tables>
                </schema>
            </schemas>
        </dataStore>
    </datastores>
</clientProperties>

My Entity Classes looks like Below

@Entity
@Table(name = "STUDENT",  schema = "UserPROFILE@hbase_pu")
public class Student{

@Id
@Column(name = "StudentID")
String StudentID
@Column(name = "Name")
String Name

}

@Entity
@Table(name = "COURCES",  schema = "UserPROFILE@hbase_pu")
public class Cource{

@Id
@Column(name = "CourceID")
String CourceID
@Column(name = "Name")
String Name

}

When I run Test Cases I get

UserPROFILE as table & STUDENT & COURCES as their column families

What I expect is

UserProfile:STUDENT as one table & UserProfile:COURCE as onother table

I feel now Keyspace in Kundera Persitence.xml takes as TableName & Entities as column family

How to Avoid This ??


Solution

  • I think you are using kundera-hbase

    <dependency>
         <groupId>com.impetus.kundera.client</groupId>
         <artifactId>kundera-hbase</artifactId>
         <version>${kundera.version}</version>
    </dependency>
    

    For your usecase, you should use kundera-hbase-v2

    <dependency>
         <groupId>com.impetus.kundera.client</groupId>
         <artifactId>kundera-hbase-v2</artifactId>
         <version>${kundera.version}</version>
    </dependency>
    

    Mapping in kundera-hbase

    • keyspace ==> hTable
    • entity ==> column family (a column family for each entity class)

    and in kundera-hbase-v2

    • keyspace ==> namespace
    • entity ==> hTable (one hTable for each entity)

    Check Kundera wiki for more details. Also, make sure you are using the latest version of Kundera.