Akka-persistence-hbase-master source analysis of the creation of journal table

Source: Internet
Author: User

Akka-persistence-hbase-master is the component responsible for Akka persistence, using the Async method to manipulate HBase, Akka logs persisted into hbase.

Akka-persistence-hbase-master to create a journal table before persisting, the configuration of the table is stored in the application.conf file.

The Akka.persistence.hbase.journal.HBaseJournalInit object is responsible for managing the journal table, and the code to get the HBase configuration is as follows:
 def gethbaseconfig (config:config): Configuration = {val c  = new   Configuration () val journalconfig  = config.getconfig ( " hbase-journal  "   = journalconfig.getconfig ( Span style= "color: #800000;" >hadoop-pass-through   )// Gets the configuration under Hadoop-pass-through//the configuration to be obtained is returned as Key:value (same as the configuration of Hbase-site.xml) Hbaseconfig.entryset (). Asscala  Span style= "color: #0000ff;" >foreach  {e => C.  set   (E.getkey, e.getvalue.unwrapped.tostring)} C}  

After getting to the configuration, you also need the table name and column family name to create the table, akka-persistence-hbase-master the table created by default is "Akka_messages", the column family name is "message", if you want to modify it, The following configuration can be added under the Hbase-journal tab of the application.conf file:

" TableName "  "familyname"

After the configuration, table name, and column family names are taken, the Doinittable method is executed (the creation table is still created with HBase's own hbaseadmin) with the following code:

Privatedef doinittable (Admin:hbaseadmin, Tablename:string, familyname:string): Boolean = {    if(Admin.tableexists (TableName)) {val Tabledesc=Admin.gettabledescriptor (Tobytes (tableName))if(Tabledesc.getfamily (Tobytes (familyname)) = =NULL) {        //Target family does not exists, would add it.Admin.addcolumn (Familyname,NewHcolumndescriptor (familyname))true      } Else {        //existing table is OK, no modifications run.        false      }    } Else{val Tabledesc=NewHtabledescriptor (Tobytes (tableName)) tabledesc.addfamily (NewHcolumndescriptor (familyname)) admin.createtable (TABLEDESC)true    }  }

The snapshot table is also created after the journal table is created, similar to journal.

Then it will execute Thread.Sleep (2000)

Akka-persistence-hbase-master source analysis of the creation of journal table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.