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