hbase - Connecting to Mapr-DB (M3) from a Java client -


i'm trying interact mapr-db table simple java application running within node of m3 mapr cluster. seems able connect cluster apparently not able connect table properly. snippet code:

configuration configuration = new configuration(); configuration.set("hbase.zookeeper.quorum", "192.168.2.1,192.168.2.2,192.168.2.3"); configuration.set("hbase.zookeeper.property.clientport", "5181"); configuration.set("mapr.htable.impl", "com.mapr.fs.maprhtable"); configuration.set("hbase.table.namespace.mappings", "*:/user/mapr/");  configuration = hbaseconfiguration.create(configuration);  hconnection connection = hconnectionmanager.createconnection(configuration);  system.out.println("is master running? " + connection.ismasterrunning());  string tablename = args[0];  htable table = (htable) connection.gettable(tablename.getbytes());  (hcolumndescriptor columnfamily : table.gettabledescriptor().getcolumnfamilies()) {     system.out.println("column family: " + columnfamily.getnameasstring()); } 

i have table called "/user/mapr/test_table" (i see in mapr web console , can access through hbase shell). running code reasonable parameter table name returns exception:

org.apache.hadoop.hbase.tablenotfoundexception: /user/mapr/test_table     @ org.apache.hadoop.hbase.client.hconnectionmanager$hconnectionimplementation.gethtabledescriptor(hconnectionmanager.java:2750)     @ org.apache.hadoop.hbase.client.htable.gettabledescriptor(htable.java:701)     @ it.noovle.bigdata.hadoop.maprdblocaltest.main(maprdblocaltest.java:49) 
  • in several places read mapr-db not necessary connect through zookeeper. true in general or m7? running m3 @ moment.
  • is there specific way address mapr-db tables java hbase api? in hbase shelli use '/user/mapr/test_table'.
  • someone can share decent example of running example m3 cluster?

to connect mapr-db, don't require connect zookeeper. open table have provide absolute path. e.g /user/mapr/test_table. attaching simple example below:

import java.io.ioexception; import java.util.arraylist; import java.util.list; import java.util.*; import org.apache.hadoop.hbase.keyvalue; import org.apache.hadoop.conf.configuration; import org.apache.hadoop.hbase.hbaseconfiguration; import org.apache.hadoop.hbase.client.get; import org.apache.hadoop.hbase.client.htable; import org.apache.hadoop.hbase.client.put; 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;  public class hbaseexample {     public static void main(string[] args) throws ioexception {         configuration config = hbaseconfiguration.create();         htable table = new htable(config, "/user/mapr/test_table");         put p = new put(bytes.tobytes("row1"));         p.add(bytes.tobytes("cf1"), bytes.tobytes("col2"),                 bytes.tobytes("abc"));          table.put(p);         g = new get(bytes.tobytes("row1"));         result r = table.get(g);         byte[] value = r.getvalue(bytes.tobytes("cf1"),                 bytes.tobytes("col2"));          string valuestr = bytes.tostring(value);         system.out.println("get: " + valuestr);         scan s = new scan();         s.addcolumn(bytes.tobytes("cf1"), bytes.tobytes("col2"));         resultscanner scanner = table.getscanner(s);         try {             (result rr = scanner.next(); rr != null; rr = scanner.next()) {                 system.out.println("found row: " + rr);             }          } {             scanner.close();         }     } } 

here hbase-site.xml, taken mapr sandbox.

-bash-4.1$ cat ./hbase/hbase-0.98.7/conf/hbase-site.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration>    <property>     <name>hbase.rootdir</name>     <value>maprfs:///hbase</value>   </property>    <property> <name>hbase.cluster.distributed</name> <value>true</value>   </property>    <property> <name>hbase.zookeeper.quorum</name> <value>maprdemo</value>   </property>    <property> <name>hbase.zookeeper.property.clientport</name> <value>5181</value>   </property>    <property>     <name>dfs.support.append</name>     <value>true</value>   </property>    <property>     <name>hbase.fsutil.maprfs.impl</name>     <value>org.apache.hadoop.hbase.util.fsmaprutils</value>   </property>    <property>     <name>hbase.regionserver.handler.count</name>     <value>30</value>     <!-- default 25 -->   </property>    <!-- uncomment enable fileclient logging   <property>     <name>fs.mapr.trace</name>     <value>debug</value>   </property>   -->    <!-- allows file/db client use 64 threads -->   <property>     <name>fs.mapr.threads</name>     <value>64</value>   </property>  </configuration> -bash-4.1$  

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -