1
1
# OBKV HBase Client
2
- OBKV HBase Client is Java Library that can be used to access data from [ OceanBase] ( https://github.com/oceanbase/oceanbase ) by [ HBase-0.94 API] ( https://svn. apache.org/repos/asf/hbase/hbase. apache.org/trunk/0.94/apidocs /index.html ) .
2
+ OBKV HBase Client is Java Library that can be used to access data from [ OceanBase] ( https://github.com/oceanbase/oceanbase ) by [ HBase-1.x API] ( https://javadoc.io/doc/org. apache.hbase/hbase-client/1.3.6/index.html ) or [ Hbase-2.x API ] ( https://javadoc.io/doc/org. apache.hbase/hbase-client/2.1.10 /index.html) .
3
3
4
4
## Quick start
5
5
@@ -32,26 +32,19 @@ Import the dependency for your maven project:
32
32
33
33
The code demo:
34
34
``` java
35
- import com.alipay.oceanbase.hbase.OHTableClient ;
36
- import org.apache.hadoop.conf.Configuration ;
37
- import org.apache.hadoop.hbase.client.Get ;
38
- import org.apache.hadoop.hbase.client.Put ;
39
- import org.apache.hadoop.hbase.client.Result ;
35
+ import org.apache.hadoop.hbase.HBaseConfiguration ;
36
+ import org.apache.hadoop.hbase.TableName ;
37
+ import org.apache.hadoop.hbase.client.* ;
40
38
41
- import static com.alipay.oceanbase.hbase.constants.OHConstants.* ;
42
39
import static org.apache.hadoop.hbase.util.Bytes.toBytes ;
43
40
44
- public class simpleTest {
45
- public static void main (String [] args ) throws Exception {
46
- // 1. initial client for table test1
47
- Configuration conf = new Configuration ();
48
- conf. set(HBASE_OCEANBASE_PARAM_URL , " PARAM_URL" );
49
- conf. set(HBASE_OCEANBASE_FULL_USER_NAME , " FULL_USER_NAME" );
50
- conf. set(HBASE_OCEANBASE_PASSWORD , " PASSWORD" );
51
- conf. set(HBASE_OCEANBASE_SYS_USER_NAME , " SYS_USER_NAME" );
52
- conf. set(HBASE_OCEANBASE_SYS_PASSWORD , " SYS_PASSWORD" );
53
- OHTableClient hTable = new OHTableClient (" test1" , conf);
54
- hTable. init();
41
+ public class SimpleHBaseClientDemo {
42
+ public static void simpleTest () throws Exception {
43
+ // 1. initial connection for table test1
44
+ HBaseConfiguration conf = new HBaseConfiguration ();
45
+ Connection connection = ConnectionFactory . createConnection(conf);
46
+ TableName tableName = TableName . valueOf(" test1" );
47
+ Table hTable = connection. getTable(tableName);
55
48
56
49
// 2. put data like hbase
57
50
byte [] family = toBytes(" family1" );
@@ -65,19 +58,98 @@ public class simpleTest {
65
58
Get get = new Get (rowKey);
66
59
get. addColumn(family, column);
67
60
Result r = hTable. get(get);
68
- System . out. printf(" column1: " + r. getColumn(family, column));
61
+ System . out. println(" column1: " + r. getColumn(family, column));
62
+
63
+ // 4. close
64
+ hTable. close();
65
+ connection. close();
66
+ }
67
+
68
+ public static void main (String [] args ) throws Exception {
69
+ simpleTest();
69
70
}
70
71
}
71
72
```
73
+
74
+ The Hbase Configuration in hbase-site.xml for direct-connect mode:
75
+ ``` xml
76
+ <configuration >
77
+ <property >
78
+ <name >hbase.client.connection.impl</name >
79
+ <value >com.alipay.oceanbase.hbase.util.OHConnectionImpl</value >
80
+ </property >
81
+ <property >
82
+ <name >hbase.oceanbase.fullUserName</name >
83
+ <value ></value >
84
+ </property >
85
+ <property >
86
+ <name >hbase.oceanbase.password</name >
87
+ <value ></value >
88
+ </property >
89
+ <property >
90
+ <name >hbase.oceanbase.paramURL</name >
91
+ <value ></value >
92
+ </property >
93
+ <property >
94
+ <name >hbase.oceanbase.sysUserName</name >
95
+ <value ></value >
96
+ </property >
97
+ <property >
98
+ <name >hbase.oceanbase.sysPassword</name >
99
+ <value ></value >
100
+ </property >
101
+ </configuration >
102
+ ```
103
+
104
+ The Hbase Configuration in hbase-site.xml for ODP mode:
105
+ ``` xml
106
+ <configuration >
107
+ <property >
108
+ <name >hbase.client.connection.impl</name >
109
+ <value >com.alipay.oceanbase.hbase.util.OHConnectionImpl</value >
110
+ </property >
111
+ <property >
112
+ <name >hbase.oceanbase.odpMode</name >
113
+ <value >true</value >
114
+ </property >
115
+ <property >
116
+ <name >hbase.oceanbase.fullUserName</name >
117
+ <value ></value >
118
+ </property >
119
+ <property >
120
+ <name >hbase.oceanbase.password</name >
121
+ <value ></value >
122
+ </property >
123
+ <property >
124
+ <name >hbase.oceanbase.odpAddr</name >
125
+ <value ></value >
126
+ </property >
127
+ <property >
128
+ <name >hbase.oceanbase.odpPort</name >
129
+ <value >3307</value >
130
+ </property >
131
+ <property >
132
+ <name >hbase.oceanbase.database</name >
133
+ <value ></value >
134
+ </property >
135
+ </configuration >
136
+ ```
137
+
72
138
** NOTE:**
73
- * param_url is generated by [ ConfigServer] ( https://ask.oceanbase.com/t/topic/35601923 )
74
- * More example [ TODO]
75
- * full_user_name: the user for accessing obkv, which format is user_name@tenant_name#cluster_name
76
- * sys_user_name: root@sys or proxy@sys, which have privileges to access routing system view
139
+ * ` hbase.client.connection.impl ` : the implementation of hbase connenction, which must be set to ` com.alipay.oceanbase.hbase.util.OHConnectionImpl `
140
+ * ` hbase.oceanbase.odpMode ` : true indicate is in ODP mode, false(in default) indicate is in direct-connect mode
141
+ * ` hbase.oceanbase.fullUserName ` : the user for accessing obkv, which format is user_name@tenant_name#cluster_name
142
+ * ` hbase.oceanbase.password ` : the password associated with the specified user
143
+ * ` hbase.oceanbase.paramURL ` : which is generated by [ ConfigServer] ( https://ask.oceanbase.com/t/topic/35601923 )
144
+ * ` hbase.oceanbase.sysUserName ` : root@sys or proxy@sys, which have privileges to access routing system view
145
+ * ` hbase.oceanbase.sysPassword ` : the password associated with the specified sys user
146
+ * ` hbase.oceanbase.odpAddr ` : the ODP's IP address
147
+ * ` hbase.oceanbase.odpPort ` : the ODP's OBKV port
148
+ * ` hbase.oceanbase.database ` : the target database to operate on
149
+
77
150
## Documentation
78
-
79
151
- English [ Coming soon]
80
- - Simplified Chinese (简体中文) [ Coming soon ]
152
+ - [ Simplified Chinese (简体中文)] ( https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000002022354 )
81
153
82
154
## Licencing
83
155
0 commit comments