Question

I currently have an HBase/Hadoop cluster running without issues, and I am fairly familiar with these products. I recently heard about Kundera, and it looks to be a very powerful tool that I would like to use.

However, I cannot seem to find any documentation/tutorials/examples for setting up Kundera with HBase. I have tried some of the materials I happened to come across, but they have failed so egregiously that I am under the impression that it wasn't relevant.

Essentially I don't know where to begin. I'm not worried about somebody explaining to me any kind of advanced level stuff, but I just cannot get this thing configured.

If anybody can point me in the right direction I would greatly appreciate it.

TLDR: I have an HBase cluster running and want to use Kundera with it and I have no clue where to begin whatsoever. Thanks.

Was it helpful?

Solution

You can start here https://github.com/impetus-opensource/Kundera and https://github.com/impetus-opensource/Kundera/wiki

Kundera is JPA compliant , it's pretty easy and straight forward to setup. wiki has enough documentation / examples to get you started. Kundera dev team is very active here as well.

Just create your persistence.xml as shown https://github.com/impetus-opensource/Kundera/wiki/Common-Configuration

and hbase specific options https://github.com/impetus-opensource/Kundera/wiki/HBase-Specific-Features

OTHER TIPS

Kundera + Hbase Configuration in Eclipse

Start your Hbase configuration on linux or others

create Dynamic web project

Add the following jar into Libraries of the project

        1)asm-4.0.jar
        2)cglib-2.1.jar
        3)commons-lang-2.5.jar
        4)commons-logging-1.1.1.jar
        5)hadoop-core-1.0.0.jar
        6)hbase-0.94.4.jar
        7)jts-1.11.jar
        8)kundera-core-2.5.1.jar
        9)kundera-hbase-2.5.jar
        10)log4j-1.2.16.jar
        11)lucene-core-3.5.0.jar
        12)xstream-1.3.1.jar
        13)zookeeper-3.3.2.jar

Add the persistence.xml file as following

        <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
            http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
            version="2.0">
            <persistence-unit name="hbase_pu">
                <provider>com.impetus.kundera.KunderaPersistence</provider> 
                <class>com.fvrl.MyObject</class>    
                <properties>            
                    <property name="kundera.nodes" value="your host ip"/>
                    <property name="kundera.port" value="port"/>
                    <property name="kundera.keyspace" value="KunderaExamples"/>
                    <property name="kundera.dialect" value="hbase"/>
                    <property name="kundera.client.lookup.class" value="com.impetus.client.hbase.HBaseClientFactory" />
                    <property name="kundera.client.property" value="yourxmlfilepath" />  
                            <property name="kundera.ddl.auto.prepare" value="update" />             
                </properties>       
            </persistence-unit>
        </persistence>

Above xml file path must be place in proper place.

Make your Entity Class as below

        @Entity
        @Table(name = "MyObject", schema = "KunderaExamples@hbase_pu")
        @NamedQueries({
          @NamedQuery(name="findAll", query="select c from MyObject c")
        })
        public class MyObject
        {

            @Id
            private String id;
            public String getId() {
                return id;
            }
            public void setId(String id) {
                this.id = id;
            }
            public String getFirstname() {
                return firstname;
            }
            public void setFirstname(String firstname) {
                this.firstname = firstname;
            }
            public String getSecondname() {
                return secondname;
            }
            public void setSecondname(String secondname) {
                this.secondname = secondname;
            }
            private String firstname;
            private String secondname;
        }

Run Your Project through main method

        public static void main(String[] args) {

                MyObject myObject = new MyObject();
                myObject.setId("0006");
                myObject.setFirstname("Nirav");
            myObject.setSecondname("shah");

                EntityManagerFactory emf = Persistence.createEntityManagerFactory("hbase_pu");
                EntityManager em = emf.createEntityManager();

               //Save  
                HBaseJPAImpl hBaseJPAImpl =new HBaseJPAImpl(em);
                hBaseJPAImpl.save(myObject);

                //retrive
                List<MyObject> list= hBaseJPAImpl.findAllDetails();

                for(MyObject myObject1 : list){
                   System.out.println("Row Id : "+myObject1.getId());
                   System.out.println("First Name : "+myObject1.getFirstname());
                   System.out.println("Last Name : "+myObject1.getSecondname());
                }
        }

HBaseJPAImpl Class is following

        public class HBaseJPAImpl implements IHBaseJPA
        {
            public HBaseJPAImpl(EntityManager em) {
                // TODO Auto-generated constructor stub
                this.em = em;
            }
          @Inject protected EntityManager em;

          @Transactional
          public void save(MyObject myObject)
          {

           // em.persist(myObject));

            EntityTransaction entityTransaction = this.em.getTransaction();
            entityTransaction.begin();

            em.persist(myObject));   

            entityTransaction.commit();

          }

          @SuppressWarnings("unchecked")
          @Override
          @Transactional
          public List<MyObject> findAllDetails()
          {
            Query query = em.createNamedQuery("findAll");
            List<MyObject> results = (List<MyObject>) query.getResultList();
            return results;
          }  
        }

        interface IHBaseJPA is below

        public interface IHBaseJPA
        {
          void save(MyObject contact);`enter code here`
          List<MyObject> findAllDetails();
        }

if find any queries on the above then contact me

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top