thrift-0.9.3.exe --gen java hbase.thrift
hbase thrift2 start hbase thrift2 stop
hbase-daemon.sh start thrift2 hbase-daemon.sh stop thrift2
[ root@bogon ~]# hbase thrift2 start SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/root/hbase-1.2.2/lib/slf4j-log4j12-1.7.5.jar!/ org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/hadoop-2.5.1/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/ org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl. Log4jLoggerFactory] 2016-09-20 08:57:05,211 INFO [main] impl. MetricsConfig: loaded properties from hadoop-metrics2-hbase.properties 2016-09-20 08:57:05,367 INFO [main] impl. MetricsSystemImpl: Scheduled snapshot period at 10 second(s). 2016-09-20 08:57:05,367 INFO [main] impl. MetricsSystemImpl: HBase metrics system started 2016-09-20 08:57:06,123 INFO [main] mortbay.log: Logging to org.slf4j.impl. Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log. Slf4jLog 2016-09-20 08:57:06,129 INFO [main] http. HttpRequestLog: Http request log for http.requests.thrift is not defined 2016-09-20 08:57:06,148 INFO [main] http. HttpServer: Added global filter 'safety' (class=org.apache.hadoop.hbase.http. HttpServer$QuotingInputFilter) 2016-09-20 08:57:06,148 INFO [main] http. HttpServer: Added global filter 'clickjackingprevention' (class=org.apache.hadoop.hbase.http. ClickjackingPreventionFilter) 2016-09-20 08:57:06,151 INFO [main] http. HttpServer: Added filter static_user_filter (class=org.apache.hadoop.hbase.http.lib. StaticUserWebFilter$StaticUserFilter) to context thrift 2016-09-20 08:57:06,151 INFO [main] http. HttpServer: Added filter static_user_filter (class=org.apache.hadoop.hbase.http.lib. StaticUserWebFilter$StaticUserFilter) to context static 2016-09-20 08:57:06,152 INFO [main] http. HttpServer: Added filter static_user_filter (class=org.apache.hadoop.hbase.http.lib. StaticUserWebFilter$StaticUserFilter) to context logs 2016-09-20 08:57:06,173 INFO [main] http. HttpServer: Jetty bound to port 9095 2016-09-20 08:57:06,174 INFO [main] mortbay.log: jetty-6.1.26 2016-09-20 08:57:06,680 INFO [main] mortbay.log: Started SelectChannelConnector@0.0.0.0 :9095 2016-09-20 08:57:06,695 INFO [main] thrift2.ThriftServer: starting HBase ThreadPool Thrift server on 0.0.0.0/0.0.0.0:9090
import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.thrift2.generated.TColumnValue; import org.apache.hadoop.hbase.thrift2.generated.THBaseService; import org.apache.hadoop.hbase.thrift2.generated.TPut; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; public class ThriftExample { public static void main(String[] args) throws Exception { TTransport transport = new TSocket("192.168.111.129", 9090, 20000); TProtocol protocol = new TBinaryProtocol(transport, true, true); THBaseService.Client client = new THBaseService.Client(protocol); transport.open(); ByteBuffer table = ByteBuffer.wrap("testTable".getBytes()); TPut put = new TPut(); put.setRow("row1".getBytes()); TColumnValue columnValue = new TColumnValue(); columnValue.setFamily("family1".getBytes()); columnValue.setQualifier("qualifier1".getBytes()); columnValue.setValue("value1".getBytes()); List<TColumnValue> columnValues = new ArrayList<TColumnValue>(); columnValues.add(columnValue); put.setColumnValues(columnValues); client.put(table, put); transport.close(); } }
hbase(main):003:0> scan 'testtable' ROW COLUMN+CELL rthrift column=colfam1:qualifier1, timestamp=1474376284145, value=value1