├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── action.go ├── action_test.go ├── admin.go ├── admin_test.go ├── call.go ├── client.go ├── client_ops.go ├── client_test.go ├── column.go ├── column_test.go ├── conn.go ├── del.go ├── del_test.go ├── get.go ├── get_test.go ├── iohelper ├── multireader.go ├── pbbuffer.go └── utils.go ├── proto ├── AccessControl.pb.go ├── Admin.pb.go ├── Aggregate.pb.go ├── Authentication.pb.go ├── Cell.pb.go ├── Client.pb.go ├── ClusterId.pb.go ├── ClusterStatus.pb.go ├── Comparator.pb.go ├── Encryption.pb.go ├── ErrorHandling.pb.go ├── FS.pb.go ├── Filter.pb.go ├── HBase.pb.go ├── HFile.pb.go ├── LoadBalancer.pb.go ├── MapReduce.pb.go ├── Master.pb.go ├── MultiRowMutation.pb.go ├── RPC.pb.go ├── RegionServerStatus.pb.go ├── RowProcessor.pb.go ├── SecureBulkLoad.pb.go ├── Snapshot.pb.go ├── Tracing.pb.go ├── VisibilityLabels.pb.go ├── WAL.pb.go └── ZooKeeper.pb.go ├── protobuf ├── AccessControl.proto ├── Admin.proto ├── Aggregate.proto ├── Authentication.proto ├── Cell.proto ├── Client.proto ├── ClusterId.proto ├── ClusterStatus.proto ├── Comparator.proto ├── Encryption.proto ├── ErrorHandling.proto ├── FS.proto ├── Filter.proto ├── HBase.proto ├── HFile.proto ├── LoadBalancer.proto ├── MapReduce.proto ├── Master.proto ├── MultiRowMutation.proto ├── RPC.proto ├── RegionServerStatus.proto ├── RowProcessor.proto ├── SecureBulkLoad.proto ├── Snapshot.proto ├── Tracing.proto ├── VisibilityLabels.proto ├── WAL.proto └── ZooKeeper.proto ├── put.go ├── put_test.go ├── result.go ├── result_test.go ├── scan.go ├── scan_test.go ├── service_call.go ├── types.go └── utils.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | *.swp 6 | 7 | # Folders 8 | _obj 9 | _test 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.5.1 5 | 6 | before_script: 7 | - cd $TRAVIS_BUILD_DIR 8 | - java -version 9 | - wget http://archive.apache.org/dist/hbase/0.98.15/hbase-0.98.15-hadoop2-bin.tar.gz 10 | - tar -zxf hbase-0.98.15-hadoop2-bin.tar.gz 11 | - hbase-0.98.15-hadoop2/bin/start-hbase.sh 12 | - sleep 60s 13 | - jps 14 | - cd $TRAVIS_BUILD_DIR 15 | 16 | script: 17 | - go test -v -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 dongxu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | 24 | Copyright (c) 2014 Bryan Peterson. All rights reserved. 25 | 26 | Redistribution and use in source and binary forms, with or without 27 | modification, are permitted provided that the following conditions are 28 | met: 29 | 30 | * Redistributions of source code must retain the above copyright 31 | notice, this list of conditions and the following disclaimer. 32 | * Redistributions in binary form must reproduce the above 33 | copyright notice, this list of conditions and the following disclaimer 34 | in the documentation and/or other materials provided with the 35 | distribution. 36 | * Neither the name of Google Inc. nor the names of its 37 | contributors may be used to endorse or promote products derived from 38 | this software without specific prior written permission. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [UNMAINTAINED] 2 | 3 | [![Build Status](https://travis-ci.org/pingcap/go-hbase.svg)](https://travis-ci.org/pingcap/go-hbase) 4 | 5 | Derived from [Lazyshot/go-hbase](https://github.com/Lazyshot/go-hbase). Add some new features and fix some bugs. 6 | 7 | ## New Features 8 | 9 | 1. Coprocessor EndPoint call. 10 | 2. Goroutine-safe. 11 | 3. Admin commands: Create/Disable/Drop table. 12 | 4. Pipelined RPC. 13 | 14 | Support HBase >= 0.98.5 15 | -------------------------------------------------------------------------------- /action.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | pb "github.com/golang/protobuf/proto" 5 | "github.com/juju/errors" 6 | "github.com/ngaut/log" 7 | "github.com/pingcap/go-hbase/proto" 8 | ) 9 | 10 | type action interface { 11 | ToProto() pb.Message 12 | } 13 | 14 | func (c *client) innerCall(table, row []byte, action action, useCache bool) (*call, error) { 15 | region, err := c.LocateRegion(table, row, useCache) 16 | if err != nil { 17 | return nil, errors.Trace(err) 18 | } 19 | 20 | conn, err := c.getClientConn(region.Server) 21 | if err != nil { 22 | return nil, errors.Trace(err) 23 | } 24 | 25 | regionSpecifier := &proto.RegionSpecifier{ 26 | Type: proto.RegionSpecifier_REGION_NAME.Enum(), 27 | Value: []byte(region.Name), 28 | } 29 | 30 | var cl *call 31 | switch a := action.(type) { 32 | case *Get: 33 | cl = newCall(&proto.GetRequest{ 34 | Region: regionSpecifier, 35 | Get: a.ToProto().(*proto.Get), 36 | }) 37 | case *Put, *Delete: 38 | cl = newCall(&proto.MutateRequest{ 39 | Region: regionSpecifier, 40 | Mutation: a.ToProto().(*proto.MutationProto), 41 | }) 42 | 43 | case *CoprocessorServiceCall: 44 | cl = newCall(&proto.CoprocessorServiceRequest{ 45 | Region: regionSpecifier, 46 | Call: a.ToProto().(*proto.CoprocessorServiceCall), 47 | }) 48 | default: 49 | return nil, errors.Errorf("Unknown action - %T - %v", action, action) 50 | } 51 | 52 | err = conn.call(cl) 53 | if err != nil { 54 | // If failed, remove bad server conn cache. 55 | cachedKey := cachedConnKey(region.Server, ClientService) 56 | delete(c.cachedConns, cachedKey) 57 | return nil, errors.Trace(err) 58 | } 59 | 60 | return cl, nil 61 | } 62 | 63 | func (c *client) innerDo(table, row []byte, action action, useCache bool) (pb.Message, error) { 64 | // Try to create and send a new resuqest call. 65 | cl, err := c.innerCall(table, row, action, useCache) 66 | if err != nil { 67 | log.Warnf("inner call failed - %v", errors.ErrorStack(err)) 68 | return nil, errors.Trace(err) 69 | } 70 | 71 | // Wait and receive the result. 72 | return <-cl.responseCh, nil 73 | } 74 | 75 | func (c *client) do(table, row []byte, action action, useCache bool) (pb.Message, error) { 76 | var ( 77 | result pb.Message 78 | err error 79 | ) 80 | 81 | LOOP: 82 | for i := 0; i < c.maxRetries; i++ { 83 | result, err = c.innerDo(table, row, action, useCache) 84 | if err == nil { 85 | switch r := result.(type) { 86 | case *exception: 87 | err = errors.New(r.msg) 88 | // If get an execption response, clean old region cache. 89 | c.CleanRegionCache(table) 90 | default: 91 | break LOOP 92 | } 93 | } 94 | 95 | useCache = false 96 | log.Warnf("Retrying action for the %d time(s), error - %v", i+1, errors.ErrorStack(err)) 97 | retrySleep(i + 1) 98 | } 99 | 100 | return result, errors.Trace(err) 101 | } 102 | -------------------------------------------------------------------------------- /action_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | pb "github.com/golang/protobuf/proto" 5 | . "github.com/pingcap/check" 6 | "github.com/pingcap/go-hbase/proto" 7 | ) 8 | 9 | type mockAction struct { 10 | } 11 | 12 | func (m *mockAction) ToProto() pb.Message { 13 | return &mockMessage{} 14 | } 15 | 16 | type mockMessage struct { 17 | } 18 | 19 | func (m *mockMessage) Reset() { 20 | } 21 | 22 | func (m *mockMessage) String() string { 23 | return "mock message" 24 | } 25 | 26 | func (m *mockMessage) ProtoMessage() { 27 | } 28 | 29 | type Message interface { 30 | Reset() 31 | String() string 32 | ProtoMessage() 33 | } 34 | 35 | type ActionTestSuit struct { 36 | cli HBaseClient 37 | tableName string 38 | } 39 | 40 | var _ = Suite(&ActionTestSuit{}) 41 | 42 | func (s *ActionTestSuit) SetUpTest(c *C) { 43 | var err error 44 | s.cli, err = NewClient(getTestZkHosts(), "/hbase") 45 | c.Assert(err, IsNil) 46 | 47 | s.tableName = "test_action" 48 | tblDesc := NewTableDesciptor(s.tableName) 49 | cf := NewColumnFamilyDescriptor("cf") 50 | tblDesc.AddColumnDesc(cf) 51 | s.cli.CreateTable(tblDesc, nil) 52 | } 53 | 54 | func (s *ActionTestSuit) TearDownTest(c *C) { 55 | err := s.cli.DisableTable(s.tableName) 56 | c.Assert(err, IsNil) 57 | 58 | err = s.cli.DropTable(s.tableName) 59 | c.Assert(err, IsNil) 60 | } 61 | 62 | func (s *ActionTestSuit) TestAction(c *C) { 63 | client, ok := s.cli.(*client) 64 | c.Assert(ok, IsTrue) 65 | 66 | row := []byte("row") 67 | unknownRow := []byte("unknownRow") 68 | value := []byte("value") 69 | p := NewPut(row) 70 | p.AddValue([]byte("cf"), []byte("q"), value) 71 | 72 | // Test put action. 73 | msg, err := client.do([]byte(s.tableName), row, p, true) 74 | c.Assert(err, IsNil) 75 | 76 | res, ok := msg.(*proto.MutateResponse) 77 | c.Assert(ok, IsTrue) 78 | c.Assert(res.GetProcessed(), IsTrue) 79 | // cachedConns includes master conn and region conn. 80 | c.Assert(client.cachedConns, HasLen, 2) 81 | // cachedRegionInfo includes table to regions mapping. 82 | c.Assert(client.cachedRegionInfo, HasLen, 1) 83 | 84 | // Test not use cache conn and check cachedConns. 85 | msg, err = client.do([]byte(s.tableName), row, p, false) 86 | c.Assert(err, IsNil) 87 | 88 | res, ok = msg.(*proto.MutateResponse) 89 | c.Assert(ok, IsTrue) 90 | c.Assert(res.GetProcessed(), IsTrue) 91 | c.Assert(client.cachedConns, HasLen, 2) 92 | c.Assert(client.cachedRegionInfo, HasLen, 1) 93 | 94 | // Test use cache conn and check cachedConns. 95 | msg, err = client.do([]byte(s.tableName), row, p, true) 96 | c.Assert(err, IsNil) 97 | 98 | res, ok = msg.(*proto.MutateResponse) 99 | c.Assert(ok, IsTrue) 100 | c.Assert(res.GetProcessed(), IsTrue) 101 | c.Assert(client.cachedConns, HasLen, 2) 102 | c.Assert(client.cachedRegionInfo, HasLen, 1) 103 | 104 | // Test put value to a none-exist table. 105 | _, err = client.do([]byte("unknown-table"), row, p, true) 106 | c.Assert(err, NotNil) 107 | c.Assert(client.cachedConns, HasLen, 2) 108 | c.Assert(client.cachedRegionInfo, HasLen, 1) 109 | 110 | // Test get action. 111 | g := NewGet(row) 112 | g.AddColumn([]byte("cf"), []byte("q")) 113 | 114 | msg, err = client.do([]byte(s.tableName), row, g, true) 115 | c.Assert(err, IsNil) 116 | 117 | gres, ok := msg.(*proto.GetResponse) 118 | c.Assert(ok, IsTrue) 119 | rr := NewResultRow(gres.GetResult()) 120 | c.Assert(rr, NotNil) 121 | c.Assert(rr.SortedColumns[0].Value, DeepEquals, value) 122 | c.Assert(client.cachedConns, HasLen, 2) 123 | c.Assert(client.cachedRegionInfo, HasLen, 1) 124 | 125 | // Test get action for an unknown row. 126 | g = NewGet(unknownRow) 127 | g.AddColumn([]byte("cf"), []byte("q")) 128 | 129 | msg, err = client.do([]byte(s.tableName), row, g, true) 130 | c.Assert(err, IsNil) 131 | 132 | gres, ok = msg.(*proto.GetResponse) 133 | c.Assert(ok, IsTrue) 134 | rr = NewResultRow(gres.GetResult()) 135 | c.Assert(rr, IsNil) 136 | c.Assert(client.cachedConns, HasLen, 2) 137 | c.Assert(client.cachedRegionInfo, HasLen, 1) 138 | 139 | // Test delete action. 140 | d := NewDelete(row) 141 | d.AddFamily([]byte("cf")) 142 | 143 | msg, err = client.do([]byte(s.tableName), row, d, true) 144 | c.Assert(err, IsNil) 145 | 146 | res, ok = msg.(*proto.MutateResponse) 147 | c.Assert(ok, IsTrue) 148 | c.Assert(res.GetProcessed(), IsTrue) 149 | c.Assert(client.cachedConns, HasLen, 2) 150 | c.Assert(client.cachedRegionInfo, HasLen, 1) 151 | 152 | // Test CoprocessorServiceCall. 153 | cs := &CoprocessorServiceCall{ 154 | Row: row, 155 | ServiceName: "ThemisService", 156 | MethodName: "themisGet", 157 | RequestParam: nil, 158 | } 159 | msg, err = client.do([]byte(s.tableName), row, cs, true) 160 | c.Assert(err, NotNil) 161 | c.Assert(client.cachedConns, HasLen, 1) 162 | c.Assert(client.cachedRegionInfo, HasLen, 1) 163 | 164 | mm := &mockMessage{} 165 | param, _ := pb.Marshal(mm) 166 | cs = &CoprocessorServiceCall{ 167 | Row: row, 168 | ServiceName: "ThemisService", 169 | MethodName: "themisGet", 170 | RequestParam: param, 171 | } 172 | msg, err = client.do([]byte(s.tableName), row, cs, true) 173 | c.Assert(err, NotNil) 174 | 175 | _, ok = msg.(*exception) 176 | c.Assert(ok, IsTrue) 177 | c.Assert(client.cachedConns, HasLen, 2) 178 | c.Assert(client.cachedRegionInfo, HasLen, 0) 179 | 180 | cs = &CoprocessorServiceCall{ 181 | Row: row, 182 | ServiceName: "UnknownService", 183 | MethodName: "UnknownMethod", 184 | RequestParam: param, 185 | } 186 | msg, err = client.do([]byte(s.tableName), row, cs, true) 187 | c.Assert(err, NotNil) 188 | 189 | _, ok = msg.(*exception) 190 | c.Assert(ok, IsTrue) 191 | c.Assert(client.cachedConns, HasLen, 2) 192 | c.Assert(client.cachedRegionInfo, HasLen, 0) 193 | 194 | // Test error. 195 | m := &mockAction{} 196 | msg, err = client.do([]byte(s.tableName), row, m, true) 197 | c.Assert(err, NotNil) 198 | c.Assert(client.cachedConns, HasLen, 2) 199 | c.Assert(client.cachedRegionInfo, HasLen, 1) 200 | } 201 | -------------------------------------------------------------------------------- /admin_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "strings" 7 | "sync" 8 | "time" 9 | 10 | "github.com/ngaut/log" 11 | . "github.com/pingcap/check" 12 | ) 13 | 14 | type AdminTestSuit struct { 15 | cli HBaseClient 16 | tableName string 17 | invalidTableName string 18 | } 19 | 20 | var ( 21 | testZks = flag.String("zk", "localhost", "hbase zookeeper info") 22 | ) 23 | 24 | func getTestZkHosts() []string { 25 | zks := strings.Split(*testZks, ",") 26 | if len(zks) == 0 { 27 | log.Fatal("invalid zk path") 28 | } 29 | return zks 30 | } 31 | 32 | var _ = Suite(&AdminTestSuit{}) 33 | 34 | func (s *AdminTestSuit) SetUpTest(c *C) { 35 | var err error 36 | s.cli, err = NewClient(getTestZkHosts(), "/hbase") 37 | c.Assert(err, IsNil) 38 | 39 | s.tableName = "test_admin" 40 | s.invalidTableName = "test_admin_xxx" 41 | tblDesc := NewTableDesciptor(s.tableName) 42 | cf := NewColumnFamilyDescriptor("cf") 43 | tblDesc.AddColumnDesc(cf) 44 | err = s.cli.CreateTable(tblDesc, [][]byte{[]byte("f"), []byte("e"), []byte("c")}) 45 | c.Assert(err, IsNil) 46 | } 47 | 48 | func (s *AdminTestSuit) TearDownTest(c *C) { 49 | err := s.cli.DisableTable(s.tableName) 50 | c.Assert(err, IsNil) 51 | err = s.cli.DropTable(s.tableName) 52 | c.Assert(err, IsNil) 53 | } 54 | 55 | func (s *AdminTestSuit) TestTable(c *C) { 56 | b, err := s.cli.TableExists(s.tableName) 57 | c.Assert(err, IsNil) 58 | c.Assert(b, IsTrue) 59 | 60 | err = s.cli.DisableTable(s.tableName) 61 | c.Assert(err, IsNil) 62 | 63 | // Wait for table disabled. 64 | time.Sleep(3 * time.Second) 65 | 66 | p := NewPut([]byte("key")) 67 | p.AddValue([]byte("cf"), []byte("f"), []byte("value")) 68 | ok, err := s.cli.Put(s.tableName, p) 69 | c.Assert(err, NotNil) 70 | c.Assert(ok, IsFalse) 71 | 72 | // Wait for table enabled. 73 | time.Sleep(3 * time.Second) 74 | 75 | err = s.cli.EnableTable(s.tableName) 76 | c.Assert(err, IsNil) 77 | 78 | ok, err = s.cli.Put(s.tableName, p) 79 | c.Assert(err, IsNil) 80 | c.Assert(ok, IsTrue) 81 | 82 | g := NewGet([]byte("key")) 83 | g.AddColumn([]byte("cf"), []byte("f")) 84 | r, err := s.cli.Get(s.tableName, g) 85 | c.Assert(err, IsNil) 86 | c.Assert(r.Columns["cf:f"].Values, HasLen, 1) 87 | c.Assert(string(r.SortedColumns[0].Value), Equals, "value") 88 | 89 | // Test check unexisted table. 90 | b, err = s.cli.TableExists(s.invalidTableName) 91 | c.Assert(err, IsNil) 92 | c.Assert(b, IsFalse) 93 | 94 | // Test disable unexisted table. 95 | err = s.cli.DisableTable(s.invalidTableName) 96 | c.Assert(err, NotNil) 97 | 98 | // Test enable unexisted table. 99 | err = s.cli.EnableTable(s.invalidTableName) 100 | c.Assert(err, NotNil) 101 | 102 | // Test drop unexisted table. 103 | err = s.cli.DropTable(s.invalidTableName) 104 | c.Assert(err, NotNil) 105 | } 106 | 107 | func (s *AdminTestSuit) TestCreateTableAsync(c *C) { 108 | wg := sync.WaitGroup{} 109 | wg.Add(10) 110 | for i := 0; i < 10; i++ { 111 | go func(i int) { 112 | defer wg.Done() 113 | tblName := fmt.Sprintf("f_%d", i) 114 | tblDesc := NewTableDesciptor(tblName) 115 | cf := NewColumnFamilyDescriptor("cf") 116 | tblDesc.AddColumnDesc(cf) 117 | tblDesc.AddColumnDesc(cf) 118 | b, err := s.cli.TableExists(tblName) 119 | c.Assert(err, IsNil) 120 | if b { 121 | // Maybe some table is in disabled state, so we must ignore this error. 122 | s.cli.DisableTable(tblName) 123 | err = s.cli.DropTable(tblName) 124 | c.Assert(err, IsNil) 125 | } 126 | err = s.cli.CreateTable(tblDesc, nil) 127 | c.Assert(err, IsNil) 128 | }(i) 129 | } 130 | wg.Wait() 131 | 132 | for i := 0; i < 10; i++ { 133 | tblName := fmt.Sprintf("f_%d", i) 134 | b, err := s.cli.TableExists(tblName) 135 | c.Assert(err, IsNil) 136 | c.Assert(b, IsTrue) 137 | 138 | err = s.cli.DisableTable(tblName) 139 | c.Assert(err, IsNil) 140 | 141 | err = s.cli.DropTable(tblName) 142 | c.Assert(err, IsNil) 143 | } 144 | } 145 | 146 | func (s *AdminTestSuit) TestGetPauseTime(c *C) { 147 | invalidRetry := -1 148 | c.Assert(getPauseTime(invalidRetry), Equals, retryPauseTime[0]*defaultRetryWaitMs) 149 | invalidRetry = len(retryPauseTime) 150 | c.Assert(getPauseTime(invalidRetry), Equals, retryPauseTime[len(retryPauseTime)-1]*defaultRetryWaitMs) 151 | } 152 | 153 | func (s *AdminTestSuit) TestGetRegions(c *C) { 154 | regions, err := s.cli.GetRegions([]byte(s.tableName), false) 155 | c.Assert(err, IsNil) 156 | c.Assert(regions, HasLen, 4) 157 | } 158 | 159 | func (s *AdminTestSuit) TestTableAutoSplit(c *C) { 160 | regions, err := s.cli.GetRegions([]byte(s.tableName), false) 161 | c.Assert(err, IsNil) 162 | c.Assert(regions, HasLen, 4) 163 | origData := map[string]map[string]string{} 164 | prefixLower := 'b' 165 | prefixUpper := 'f' 166 | for prefix := prefixLower; prefix < prefixUpper; prefix++ { 167 | // b_0, b_1, ... 168 | // If insert few row, it may not be splited even invoke Split explicitly. 169 | for i := 0; i < 10000; i++ { 170 | p := NewPut([]byte(fmt.Sprintf("%c_%d", prefix, i))) 171 | p.AddStringValue("cf", "c", fmt.Sprintf("%c%c_%d", prefix, prefix, i)) 172 | rowKey := string(p.Row) 173 | origData[rowKey] = map[string]string{} 174 | origData[rowKey]["cf:c"] = string(p.Values[0][0]) 175 | b, err := s.cli.Put(s.tableName, p) 176 | c.Assert(err, IsNil) 177 | c.Assert(b, IsTrue) 178 | } 179 | } 180 | err = s.cli.Split(s.tableName, "") 181 | c.Assert(err, IsNil) 182 | // Sleep wait Split finish. 183 | time.Sleep(5 * time.Second) 184 | 185 | regions, err = s.cli.GetRegions([]byte(s.tableName), false) 186 | c.Assert(err, IsNil) 187 | // After insert 10K data, 188 | // with Themis coprocessor, it will be split to 7 regions, 189 | // without themis, that number will be 6. 190 | // Split depends on coprocessor behavior and hbase conf, 191 | // so we just know it will split at least one region. 192 | c.Assert(len(regions), Greater, 4) 193 | 194 | // Check all data are still. 195 | scan := NewScan([]byte(s.tableName), 1000, s.cli) 196 | cnt := 0 197 | for prefix := prefixLower; prefix < prefixUpper; prefix++ { 198 | for i := 0; i < 10000; i++ { 199 | r := scan.Next() 200 | c.Assert(r, NotNil) 201 | rowKey := string(r.Row) 202 | origRow, ok := origData[rowKey] 203 | c.Assert(ok, IsTrue) 204 | c.Assert(origRow, NotNil) 205 | for column := range r.Columns { 206 | origValue, ok := origRow[column] 207 | c.Assert(ok, IsTrue) 208 | value := string(r.Columns[column].Value) 209 | c.Assert(origValue, Equals, value) 210 | } 211 | delete(origData, rowKey) 212 | cnt++ 213 | } 214 | } 215 | c.Assert(cnt, Equals, int(prefixUpper-prefixLower)*10000) 216 | } 217 | 218 | func (s *AdminTestSuit) TestTableSplit(c *C) { 219 | regions, err := s.cli.GetRegions([]byte(s.tableName), false) 220 | c.Assert(err, IsNil) 221 | c.Assert(regions, HasLen, 4) 222 | for i := 0; i < 100; i++ { 223 | p := NewPut([]byte(fmt.Sprintf("b_%d", i))) 224 | p.AddStringValue("cf", "c", fmt.Sprintf("bb_%d", i)) 225 | b, err := s.cli.Put(s.tableName, p) 226 | c.Assert(err, IsNil) 227 | c.Assert(b, IsTrue) 228 | } 229 | err = s.cli.Split(s.tableName, "b_2") 230 | c.Assert(err, IsNil) 231 | 232 | // Sleep wait Split finish. 233 | time.Sleep(500 * time.Millisecond) 234 | 235 | regions, err = s.cli.GetRegions([]byte(s.tableName), false) 236 | c.Assert(err, IsNil) 237 | c.Assert(regions, HasLen, 5) 238 | 239 | // Test directly split region. 240 | err = s.cli.Split(regions[1].Name, "b_50") 241 | c.Assert(err, IsNil) 242 | 243 | // Sleep wait Split finish. 244 | time.Sleep(500 * time.Millisecond) 245 | 246 | regions, err = s.cli.GetRegions([]byte(s.tableName), false) 247 | c.Assert(err, IsNil) 248 | c.Assert(regions, HasLen, 6) 249 | 250 | } 251 | -------------------------------------------------------------------------------- /call.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "strings" 5 | 6 | pb "github.com/golang/protobuf/proto" 7 | "github.com/pingcap/go-hbase/proto" 8 | ) 9 | 10 | type call struct { 11 | id uint32 12 | methodName string 13 | request pb.Message 14 | responseBuffer pb.Message 15 | responseCh chan pb.Message 16 | } 17 | 18 | type exception struct { 19 | msg string 20 | } 21 | 22 | func isNotInRegionError(err error) bool { 23 | return strings.Contains(err.Error(), "org.apache.hadoop.hbase.NotServingRegionException") 24 | } 25 | func isUnknownScannerError(err error) bool { 26 | return strings.Contains(err.Error(), "org.apache.hadoop.hbase.UnknownScannerException") 27 | } 28 | 29 | func (m *exception) Reset() { *m = exception{} } 30 | func (m *exception) String() string { return m.msg } 31 | func (m *exception) ProtoMessage() {} 32 | 33 | func newCall(request pb.Message) *call { 34 | var responseBuffer pb.Message 35 | var methodName string 36 | 37 | switch request.(type) { 38 | case *proto.GetRequest: 39 | responseBuffer = &proto.GetResponse{} 40 | methodName = "Get" 41 | case *proto.MutateRequest: 42 | responseBuffer = &proto.MutateResponse{} 43 | methodName = "Mutate" 44 | case *proto.ScanRequest: 45 | responseBuffer = &proto.ScanResponse{} 46 | methodName = "Scan" 47 | case *proto.GetTableDescriptorsRequest: 48 | responseBuffer = &proto.GetTableDescriptorsResponse{} 49 | methodName = "GetTableDescriptors" 50 | case *proto.CoprocessorServiceRequest: 51 | responseBuffer = &proto.CoprocessorServiceResponse{} 52 | methodName = "ExecService" 53 | case *proto.CreateTableRequest: 54 | responseBuffer = &proto.CreateTableResponse{} 55 | methodName = "CreateTable" 56 | case *proto.DisableTableRequest: 57 | responseBuffer = &proto.DisableTableResponse{} 58 | methodName = "DisableTable" 59 | case *proto.EnableTableRequest: 60 | responseBuffer = &proto.EnableTableResponse{} 61 | methodName = "EnableTable" 62 | case *proto.DeleteTableRequest: 63 | responseBuffer = &proto.DeleteTableResponse{} 64 | methodName = "DeleteTable" 65 | case *proto.MultiRequest: 66 | responseBuffer = &proto.MultiResponse{} 67 | methodName = "Multi" 68 | case *proto.SplitRegionRequest: 69 | responseBuffer = &proto.SplitRegionResponse{} 70 | methodName = "SplitRegion" 71 | } 72 | 73 | return &call{ 74 | methodName: methodName, 75 | request: request, 76 | responseBuffer: responseBuffer, 77 | responseCh: make(chan pb.Message, 1), 78 | } 79 | } 80 | 81 | func (c *call) complete(err error, response []byte) { 82 | defer close(c.responseCh) 83 | 84 | if err != nil { 85 | c.responseCh <- &exception{ 86 | msg: err.Error(), 87 | } 88 | return 89 | } 90 | 91 | err = pb.Unmarshal(response, c.responseBuffer) 92 | if err != nil { 93 | c.responseCh <- &exception{ 94 | msg: err.Error(), 95 | } 96 | return 97 | } 98 | 99 | c.responseCh <- c.responseBuffer 100 | } 101 | -------------------------------------------------------------------------------- /client_ops.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "github.com/juju/errors" 5 | "github.com/pingcap/go-hbase/proto" 6 | ) 7 | 8 | func (c *client) Delete(table string, del *Delete) (bool, error) { 9 | response, err := c.do([]byte(table), del.GetRow(), del, true) 10 | if err != nil { 11 | return false, errors.Trace(err) 12 | } 13 | 14 | switch r := response.(type) { 15 | case *proto.MutateResponse: 16 | return r.GetProcessed(), nil 17 | } 18 | return false, errors.Errorf("Invalid response seen [response: %#v]", response) 19 | } 20 | 21 | func (c *client) Get(table string, get *Get) (*ResultRow, error) { 22 | response, err := c.do([]byte(table), get.GetRow(), get, true) 23 | if err != nil { 24 | return nil, errors.Trace(err) 25 | } 26 | 27 | switch r := response.(type) { 28 | case *proto.GetResponse: 29 | res := r.GetResult() 30 | if res == nil { 31 | return nil, errors.Errorf("Empty response: [table=%s] [row=%q]", table, get.GetRow()) 32 | } 33 | 34 | return NewResultRow(res), nil 35 | case *exception: 36 | return nil, errors.New(r.msg) 37 | } 38 | return nil, errors.Errorf("Invalid response seen [response: %#v]", response) 39 | } 40 | 41 | func (c *client) Put(table string, put *Put) (bool, error) { 42 | response, err := c.do([]byte(table), put.GetRow(), put, true) 43 | if err != nil { 44 | return false, errors.Trace(err) 45 | } 46 | 47 | switch r := response.(type) { 48 | case *proto.MutateResponse: 49 | return r.GetProcessed(), nil 50 | } 51 | return false, errors.Errorf("Invalid response seen [response: %#v]", response) 52 | } 53 | 54 | func (c *client) ServiceCall(table string, call *CoprocessorServiceCall) (*proto.CoprocessorServiceResponse, error) { 55 | response, err := c.do([]byte(table), call.Row, call, true) 56 | if err != nil { 57 | return nil, errors.Trace(err) 58 | } 59 | 60 | switch r := response.(type) { 61 | case *proto.CoprocessorServiceResponse: 62 | return r, nil 63 | case *exception: 64 | return nil, errors.New(r.msg) 65 | } 66 | return nil, errors.Errorf("Invalid response seen [response: %#v]", response) 67 | } 68 | -------------------------------------------------------------------------------- /client_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import . "github.com/pingcap/check" 4 | 5 | type ClientTestSuit struct { 6 | cli HBaseClient 7 | } 8 | 9 | var _ = Suite(&ClientTestSuit{}) 10 | 11 | func (s *ClientTestSuit) SetUpSuite(c *C) { 12 | } 13 | 14 | func (s *ClientTestSuit) TearDownSuite(c *C) { 15 | } 16 | 17 | func (s *ClientTestSuit) TestCreateRegionName(c *C) { 18 | table := "t" 19 | startKey := "key" 20 | id := "1234" 21 | newFormat := false 22 | mockClient := &client{} 23 | 24 | name := mockClient.createRegionName([]byte(table), []byte(startKey), id, newFormat) 25 | c.Assert(string(name), Equals, "t,key,1234") 26 | 27 | startKey = "" 28 | name = mockClient.createRegionName([]byte(table), []byte(startKey), id, newFormat) 29 | c.Assert(string(name), Equals, "t,\x00,1234") 30 | 31 | newFormat = true 32 | name = mockClient.createRegionName([]byte(table), []byte(startKey), id, newFormat) 33 | c.Assert(string(name), Equals, "t,\x00,1234.0b33d053d09ba72744f058890ed449b2.") 34 | } 35 | -------------------------------------------------------------------------------- /column.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | 8 | "github.com/juju/errors" 9 | "github.com/pingcap/go-hbase/iohelper" 10 | ) 11 | 12 | type Column struct { 13 | Family []byte 14 | Qual []byte 15 | } 16 | 17 | func NewColumn(family, qual []byte) *Column { 18 | return &Column{ 19 | Family: family, 20 | Qual: qual, 21 | } 22 | } 23 | 24 | func encode(parts ...[]byte) ([]byte, error) { 25 | buf := &bytes.Buffer{} 26 | for _, p := range parts { 27 | err := iohelper.WriteVarBytes(buf, p) 28 | if err != nil { 29 | return nil, errors.Trace(err) 30 | } 31 | } 32 | return buf.Bytes(), nil 33 | } 34 | 35 | func decode(encoded []byte) ([][]byte, error) { 36 | var ret [][]byte 37 | buf := bytes.NewBuffer(encoded) 38 | for { 39 | b, err := iohelper.ReadVarBytes(buf) 40 | if len(b) == 0 || (err != nil && ErrorEqual(err, io.EOF)) { 41 | break 42 | } 43 | ret = append(ret, b) 44 | } 45 | return ret, nil 46 | } 47 | 48 | func (c *Column) Write(w io.Writer) error { 49 | err := iohelper.WriteVarBytes(w, c.Family) 50 | if err != nil { 51 | return errors.Trace(err) 52 | } 53 | 54 | err = iohelper.WriteVarBytes(w, c.Qual) 55 | if err != nil { 56 | return errors.Trace(err) 57 | } 58 | 59 | return nil 60 | } 61 | 62 | func (c *Column) String() string { 63 | b, err := encode(c.Family, c.Qual) 64 | if err != nil { 65 | return fmt.Sprintf("invalid column - %v", err) 66 | } 67 | return string(b) 68 | } 69 | 70 | func (c *Column) ParseFromString(s string) error { 71 | pairs, err := decode([]byte(s)) 72 | if err != nil { 73 | return errors.Trace(err) 74 | } 75 | 76 | c.Family = pairs[0] 77 | c.Qual = pairs[1] 78 | return nil 79 | } 80 | 81 | type ColumnCoordinate struct { 82 | Table []byte 83 | Row []byte 84 | Column 85 | } 86 | 87 | func NewColumnCoordinate(table, row, family, qual []byte) *ColumnCoordinate { 88 | return &ColumnCoordinate{ 89 | Table: table, 90 | Row: row, 91 | Column: Column{ 92 | Family: family, 93 | Qual: qual, 94 | }, 95 | } 96 | } 97 | 98 | func (c *ColumnCoordinate) Write(w io.Writer) error { 99 | err := iohelper.WriteVarBytes(w, c.Table) 100 | if err != nil { 101 | return errors.Trace(err) 102 | } 103 | 104 | err = iohelper.WriteVarBytes(w, c.Row) 105 | if err != nil { 106 | return errors.Trace(err) 107 | } 108 | 109 | err = c.Column.Write(w) 110 | if err != nil { 111 | return errors.Trace(err) 112 | } 113 | 114 | return nil 115 | } 116 | 117 | func (c *ColumnCoordinate) Equal(a *ColumnCoordinate) bool { 118 | return bytes.Compare(c.Table, a.Table) == 0 && 119 | bytes.Compare(c.Row, a.Row) == 0 && 120 | bytes.Compare(c.Family, a.Family) == 0 && 121 | bytes.Compare(c.Qual, a.Qual) == 0 122 | } 123 | 124 | func (c *ColumnCoordinate) String() string { 125 | b, err := encode(c.Table, c.Row, c.Family, c.Qual) 126 | if err != nil { 127 | return fmt.Sprintf("invalid column coordinate - %v", err) 128 | } 129 | return string(b) 130 | } 131 | 132 | func (c *ColumnCoordinate) ParseFromString(s string) error { 133 | pairs, err := decode([]byte(s)) 134 | if err != nil { 135 | return errors.Trace(err) 136 | } 137 | 138 | c.Table = pairs[0] 139 | c.Row = pairs[1] 140 | c.Family = pairs[2] 141 | c.Qual = pairs[3] 142 | return nil 143 | } 144 | 145 | func (c *ColumnCoordinate) ParseField(b iohelper.ByteMultiReader) error { 146 | table, err := iohelper.ReadVarBytes(b) 147 | if err != nil { 148 | return errors.Trace(err) 149 | } 150 | c.Table = table 151 | 152 | row, err := iohelper.ReadVarBytes(b) 153 | if err != nil { 154 | return errors.Trace(err) 155 | } 156 | c.Row = row 157 | 158 | family, err := iohelper.ReadVarBytes(b) 159 | if err != nil { 160 | return errors.Trace(err) 161 | } 162 | c.Family = family 163 | 164 | qual, err := iohelper.ReadVarBytes(b) 165 | if err != nil { 166 | return errors.Trace(err) 167 | } 168 | c.Qual = qual 169 | return nil 170 | } 171 | 172 | func (c *ColumnCoordinate) GetColumn() *Column { 173 | return &Column{ 174 | Family: c.Family, 175 | Qual: c.Qual, 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /column_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | . "github.com/pingcap/check" 8 | ) 9 | 10 | func Test(t *testing.T) { TestingT(t) } 11 | 12 | type ColumnTestSuit struct{} 13 | 14 | var _ = Suite(&ColumnTestSuit{}) 15 | 16 | func (s *ColumnTestSuit) TestColumn(c *C) { 17 | col := NewColumn([]byte("cf"), []byte("q")) 18 | c.Assert(bytes.Compare(col.Family, []byte("cf")), Equals, 0) 19 | c.Assert(bytes.Compare(col.Qual, []byte("q")), Equals, 0) 20 | 21 | c.Assert(bytes.Compare(col.Family, []byte("cf")), Equals, 0) 22 | c.Assert(bytes.Compare(col.Qual, []byte("q")), Equals, 0) 23 | 24 | buf := bytes.NewBuffer(nil) 25 | err := col.Write(buf) 26 | c.Assert(err, IsNil) 27 | c.Assert(buf.Bytes(), HasLen, 5) 28 | } 29 | 30 | func (s *ColumnTestSuit) TestColumnCoordinate(c *C) { 31 | cc := NewColumnCoordinate([]byte("tbl"), 32 | []byte("row"), []byte("cf"), []byte("q")) 33 | 34 | buf := bytes.NewBuffer(nil) 35 | err := cc.Write(buf) 36 | c.Assert(err, IsNil) 37 | c.Assert(buf.Bytes(), HasLen, 13) 38 | 39 | cc2 := NewColumnCoordinate([]byte("tbl1"), 40 | []byte("row"), []byte("cf"), []byte("q")) 41 | 42 | c.Assert(cc.Equal(cc2), IsFalse) 43 | cc2.Table = []byte("tbl") 44 | c.Assert(cc.Equal(cc2), IsTrue) 45 | 46 | c.Assert(cc.String(), Equals, "\x03tbl\x03row\x02cf\x01q") 47 | } 48 | -------------------------------------------------------------------------------- /conn.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "io" 7 | "net" 8 | "strings" 9 | "sync" 10 | 11 | pb "github.com/golang/protobuf/proto" 12 | "github.com/juju/errors" 13 | "github.com/ngaut/log" 14 | "github.com/pingcap/go-hbase/iohelper" 15 | "github.com/pingcap/go-hbase/proto" 16 | ) 17 | 18 | type ServiceType byte 19 | 20 | const ( 21 | MasterMonitorService = iota + 1 22 | MasterService 23 | MasterAdminService 24 | AdminService 25 | ClientService 26 | RegionServerStatusService 27 | ) 28 | 29 | // convert above const to protobuf string 30 | var ServiceString = map[ServiceType]string{ 31 | MasterMonitorService: "MasterMonitorService", 32 | MasterService: "MasterService", 33 | MasterAdminService: "MasterAdminService", 34 | AdminService: "AdminService", 35 | ClientService: "ClientService", 36 | RegionServerStatusService: "RegionServerStatusService", 37 | } 38 | 39 | type idGenerator struct { 40 | n int 41 | mu *sync.RWMutex 42 | } 43 | 44 | func newIdGenerator() *idGenerator { 45 | return &idGenerator{ 46 | n: 0, 47 | mu: &sync.RWMutex{}, 48 | } 49 | } 50 | 51 | func (a *idGenerator) get() int { 52 | a.mu.RLock() 53 | v := a.n 54 | a.mu.RUnlock() 55 | return v 56 | } 57 | 58 | func (a *idGenerator) incrAndGet() int { 59 | a.mu.Lock() 60 | a.n++ 61 | v := a.n 62 | a.mu.Unlock() 63 | return v 64 | } 65 | 66 | type connection struct { 67 | mu sync.Mutex 68 | addr string 69 | conn net.Conn 70 | bw *bufio.Writer 71 | idGen *idGenerator 72 | serviceType ServiceType 73 | in chan *iohelper.PbBuffer 74 | ongoingCalls map[int]*call 75 | } 76 | 77 | func processMessage(msg []byte) ([][]byte, error) { 78 | buf := pb.NewBuffer(msg) 79 | payloads := make([][]byte, 0) 80 | 81 | // Question: why can we ignore this error? 82 | for { 83 | hbytes, err := buf.DecodeRawBytes(true) 84 | if err != nil { 85 | // Check whether error is `unexpected EOF`. 86 | if strings.Contains(err.Error(), "unexpected EOF") { 87 | break 88 | } 89 | 90 | log.Errorf("Decode raw bytes error - %v", errors.ErrorStack(err)) 91 | return nil, errors.Trace(err) 92 | } 93 | 94 | payloads = append(payloads, hbytes) 95 | } 96 | 97 | return payloads, nil 98 | } 99 | 100 | func readPayloads(r io.Reader) ([][]byte, error) { 101 | nBytesExpecting, err := iohelper.ReadInt32(r) 102 | if err != nil { 103 | return nil, errors.Trace(err) 104 | } 105 | 106 | if nBytesExpecting > 0 { 107 | buf, err := iohelper.ReadN(r, nBytesExpecting) 108 | // Question: why should we return error only when we get an io.EOF error? 109 | if err != nil && ErrorEqual(err, io.EOF) { 110 | return nil, errors.Trace(err) 111 | } 112 | 113 | payloads, err := processMessage(buf) 114 | if err != nil { 115 | return nil, errors.Trace(err) 116 | } 117 | 118 | if len(payloads) > 0 { 119 | return payloads, nil 120 | } 121 | } 122 | return nil, errors.New("unexpected payload") 123 | } 124 | 125 | func newConnection(addr string, srvType ServiceType) (*connection, error) { 126 | conn, err := net.Dial("tcp", addr) 127 | if err != nil { 128 | return nil, errors.Trace(err) 129 | } 130 | if _, ok := ServiceString[srvType]; !ok { 131 | return nil, errors.Errorf("unexpected service type [serviceType=%d]", srvType) 132 | } 133 | c := &connection{ 134 | addr: addr, 135 | bw: bufio.NewWriter(conn), 136 | conn: conn, 137 | in: make(chan *iohelper.PbBuffer, 20), 138 | serviceType: srvType, 139 | idGen: newIdGenerator(), 140 | ongoingCalls: map[int]*call{}, 141 | } 142 | 143 | err = c.init() 144 | if err != nil { 145 | return nil, errors.Trace(err) 146 | } 147 | 148 | return c, nil 149 | } 150 | 151 | func (c *connection) init() error { 152 | err := c.writeHead() 153 | if err != nil { 154 | return errors.Trace(err) 155 | } 156 | 157 | err = c.writeConnectionHeader() 158 | if err != nil { 159 | return errors.Trace(err) 160 | } 161 | 162 | go func() { 163 | err := c.processMessages() 164 | if err != nil { 165 | log.Warnf("process messages failed - %v", errors.ErrorStack(err)) 166 | return 167 | } 168 | }() 169 | go c.dispatch() 170 | return nil 171 | } 172 | 173 | func (c *connection) processMessages() error { 174 | for { 175 | msgs, err := readPayloads(c.conn) 176 | if err != nil { 177 | return errors.Trace(err) 178 | } 179 | 180 | var rh proto.ResponseHeader 181 | err = pb.Unmarshal(msgs[0], &rh) 182 | if err != nil { 183 | return errors.Trace(err) 184 | } 185 | 186 | callId := rh.GetCallId() 187 | c.mu.Lock() 188 | call, ok := c.ongoingCalls[int(callId)] 189 | if !ok { 190 | c.mu.Unlock() 191 | return errors.Errorf("Invalid call id: %d", callId) 192 | } 193 | delete(c.ongoingCalls, int(callId)) 194 | c.mu.Unlock() 195 | 196 | exception := rh.GetException() 197 | if exception != nil { 198 | call.complete(errors.Errorf("Exception returned: %s\n%s", exception.GetExceptionClassName(), exception.GetStackTrace()), nil) 199 | } else if len(msgs) == 2 { 200 | call.complete(nil, msgs[1]) 201 | } 202 | } 203 | } 204 | 205 | func (c *connection) writeHead() error { 206 | buf := bytes.NewBuffer(nil) 207 | buf.Write(hbaseHeaderBytes) 208 | buf.WriteByte(0) 209 | buf.WriteByte(80) 210 | _, err := c.conn.Write(buf.Bytes()) 211 | return errors.Trace(err) 212 | } 213 | 214 | func (c *connection) writeConnectionHeader() error { 215 | buf := iohelper.NewPbBuffer() 216 | service := pb.String(ServiceString[c.serviceType]) 217 | 218 | err := buf.WritePBMessage(&proto.ConnectionHeader{ 219 | UserInfo: &proto.UserInformation{ 220 | EffectiveUser: pb.String("pingcap"), 221 | }, 222 | ServiceName: service, 223 | }) 224 | if err != nil { 225 | return errors.Trace(err) 226 | } 227 | 228 | err = buf.PrependSize() 229 | if err != nil { 230 | return errors.Trace(err) 231 | } 232 | 233 | _, err = c.conn.Write(buf.Bytes()) 234 | if err != nil { 235 | return errors.Trace(err) 236 | } 237 | 238 | return nil 239 | } 240 | 241 | func (c *connection) dispatch() { 242 | for { 243 | select { 244 | case buf := <-c.in: 245 | // TODO: add error check. 246 | c.bw.Write(buf.Bytes()) 247 | if len(c.in) == 0 { 248 | c.bw.Flush() 249 | } 250 | } 251 | } 252 | } 253 | 254 | func (c *connection) call(request *call) error { 255 | id := c.idGen.incrAndGet() 256 | rh := &proto.RequestHeader{ 257 | CallId: pb.Uint32(uint32(id)), 258 | MethodName: pb.String(request.methodName), 259 | RequestParam: pb.Bool(true), 260 | } 261 | 262 | request.id = uint32(id) 263 | 264 | bfrh := iohelper.NewPbBuffer() 265 | err := bfrh.WritePBMessage(rh) 266 | if err != nil { 267 | return errors.Trace(err) 268 | } 269 | 270 | bfr := iohelper.NewPbBuffer() 271 | err = bfr.WritePBMessage(request.request) 272 | if err != nil { 273 | return errors.Trace(err) 274 | } 275 | 276 | // Buf => 277 | // | total size | pb1 size | pb1 | pb2 size | pb2 | ... 278 | buf := iohelper.NewPbBuffer() 279 | buf.WriteDelimitedBuffers(bfrh, bfr) 280 | 281 | c.mu.Lock() 282 | c.ongoingCalls[id] = request 283 | c.in <- buf 284 | c.mu.Unlock() 285 | 286 | return nil 287 | } 288 | 289 | func (c *connection) close() error { 290 | return c.conn.Close() 291 | } 292 | -------------------------------------------------------------------------------- /del.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | pb "github.com/golang/protobuf/proto" 5 | "github.com/pingcap/go-hbase/proto" 6 | 7 | "fmt" 8 | "math" 9 | "strings" 10 | ) 11 | 12 | type Delete struct { 13 | Row []byte 14 | Families set 15 | FamilyQuals map[string]set 16 | Ts map[string]uint64 17 | } 18 | 19 | func NewDelete(row []byte) *Delete { 20 | return &Delete{ 21 | Row: row, 22 | Families: newSet(), 23 | FamilyQuals: make(map[string]set), 24 | Ts: make(map[string]uint64), 25 | } 26 | } 27 | 28 | func (d *Delete) AddString(famqual string) error { 29 | parts := strings.Split(famqual, ":") 30 | 31 | if len(parts) > 2 { 32 | return fmt.Errorf("Too many colons were found in the family:qualifier string. '%s'", famqual) 33 | } else if len(parts) == 2 { 34 | d.AddStringColumn(parts[0], parts[1]) 35 | } else { 36 | d.AddStringFamily(famqual) 37 | } 38 | 39 | return nil 40 | } 41 | 42 | func (d *Delete) GetRow() []byte { 43 | return d.Row 44 | } 45 | 46 | func (d *Delete) AddColumn(family, qual []byte) *Delete { 47 | d.AddFamily(family) 48 | d.FamilyQuals[string(family)].add(string(qual)) 49 | return d 50 | } 51 | 52 | func (d *Delete) AddStringColumn(family, qual string) *Delete { 53 | return d.AddColumn([]byte(family), []byte(qual)) 54 | } 55 | 56 | func (d *Delete) AddFamily(family []byte) *Delete { 57 | d.Families.add(string(family)) 58 | if _, ok := d.FamilyQuals[string(family)]; !ok { 59 | d.FamilyQuals[string(family)] = newSet() 60 | } 61 | return d 62 | } 63 | 64 | func (d *Delete) AddStringFamily(family string) *Delete { 65 | return d.AddFamily([]byte(family)) 66 | } 67 | 68 | func (d *Delete) AddColumnWithTimestamp(family, qual []byte, ts uint64) *Delete { 69 | d.AddColumn(family, qual) 70 | k := string(family) + ":" + string(qual) 71 | d.Ts[k] = ts 72 | return d 73 | } 74 | 75 | func (d *Delete) ToProto() pb.Message { 76 | del := &proto.MutationProto{ 77 | Row: d.Row, 78 | MutateType: proto.MutationProto_DELETE.Enum(), 79 | } 80 | 81 | for family := range d.Families { 82 | cv := &proto.MutationProto_ColumnValue{ 83 | Family: []byte(family), 84 | QualifierValue: make([]*proto.MutationProto_ColumnValue_QualifierValue, 0), 85 | } 86 | 87 | if len(d.FamilyQuals[family]) == 0 { 88 | cv.QualifierValue = append(cv.QualifierValue, &proto.MutationProto_ColumnValue_QualifierValue{ 89 | Qualifier: nil, 90 | Timestamp: pb.Uint64(uint64(math.MaxInt64)), 91 | DeleteType: proto.MutationProto_DELETE_FAMILY.Enum(), 92 | }) 93 | } 94 | 95 | for qual := range d.FamilyQuals[family] { 96 | v := &proto.MutationProto_ColumnValue_QualifierValue{ 97 | Qualifier: []byte(qual), 98 | Timestamp: pb.Uint64(uint64(math.MaxInt64)), 99 | DeleteType: proto.MutationProto_DELETE_MULTIPLE_VERSIONS.Enum(), 100 | } 101 | tsKey := string(family) + ":" + string(qual) 102 | if ts, ok := d.Ts[tsKey]; ok { 103 | v.Timestamp = pb.Uint64(ts) 104 | v.DeleteType = proto.MutationProto_DELETE_ONE_VERSION.Enum() 105 | } 106 | cv.QualifierValue = append(cv.QualifierValue, v) 107 | } 108 | 109 | del.ColumnValue = append(del.ColumnValue, cv) 110 | } 111 | 112 | return del 113 | } 114 | -------------------------------------------------------------------------------- /del_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | . "github.com/pingcap/check" 5 | "github.com/pingcap/go-hbase/proto" 6 | ) 7 | 8 | type HBaseDelTestSuit struct { 9 | cli HBaseClient 10 | tableName string 11 | } 12 | 13 | var _ = Suite(&HBaseDelTestSuit{}) 14 | 15 | func (s *HBaseDelTestSuit) SetUpTest(c *C) { 16 | var err error 17 | s.cli, err = NewClient(getTestZkHosts(), "/hbase") 18 | c.Assert(err, IsNil) 19 | 20 | s.tableName = "t2" 21 | tblDesc := NewTableDesciptor(s.tableName) 22 | cf := NewColumnFamilyDescriptor("cf") 23 | tblDesc.AddColumnDesc(cf) 24 | err = s.cli.CreateTable(tblDesc, nil) 25 | c.Assert(err, IsNil) 26 | } 27 | 28 | func (s *HBaseDelTestSuit) TearDownTest(c *C) { 29 | err := s.cli.DisableTable(s.tableName) 30 | c.Assert(err, IsNil) 31 | 32 | err = s.cli.DropTable(s.tableName) 33 | c.Assert(err, IsNil) 34 | } 35 | 36 | func (s *HBaseDelTestSuit) TestDel(c *C) { 37 | d := NewDelete([]byte("hello")) 38 | d.AddFamily([]byte("cf")) 39 | d.AddFamily([]byte("cf1")) 40 | msg := d.ToProto() 41 | 42 | p, ok := msg.(*proto.MutationProto) 43 | c.Assert(ok, IsTrue) 44 | c.Assert(string(p.Row), Equals, "hello") 45 | c.Assert(*p.MutateType, Equals, *proto.MutationProto_DELETE.Enum()) 46 | 47 | cv := p.GetColumnValue() 48 | c.Assert(cv, HasLen, 2) 49 | 50 | for _, v := range cv { 51 | c.Assert(v.QualifierValue, HasLen, 1) 52 | c.Assert(*v.QualifierValue[0].DeleteType, Equals, *proto.MutationProto_DELETE_FAMILY.Enum()) 53 | } 54 | 55 | d = NewDelete([]byte("hello")) 56 | d.AddStringColumn("cf\x00", "q") 57 | d.AddStringColumn("cf", "q") 58 | d.AddStringColumn("cf", "q") 59 | msg = d.ToProto() 60 | p, _ = msg.(*proto.MutationProto) 61 | cv = p.GetColumnValue() 62 | c.Assert(cv, HasLen, 2) 63 | 64 | for _, v := range cv { 65 | c.Assert(v.QualifierValue, HasLen, 1) 66 | c.Assert(*v.QualifierValue[0].DeleteType, Equals, *proto.MutationProto_DELETE_MULTIPLE_VERSIONS.Enum()) 67 | } 68 | } 69 | 70 | func (s *HBaseDelTestSuit) TestDelWithClient(c *C) { 71 | // Test put a new value. 72 | p := NewPut([]byte("test")) 73 | p.AddValue([]byte("cf"), []byte("q"), []byte("val")) 74 | ok, err := s.cli.Put(s.tableName, p) 75 | c.Assert(ok, IsTrue) 76 | c.Assert(err, IsNil) 77 | 78 | g := NewGet([]byte("test")) 79 | g.AddStringFamily("cf") 80 | r, err := s.cli.Get(s.tableName, g) 81 | c.Assert(err, IsNil) 82 | c.Assert(string(r.Columns["cf:q"].Value), Equals, "val") 83 | 84 | // Test delte the value. 85 | d := NewDelete([]byte("test")) 86 | d.AddColumn([]byte("cf"), []byte("q")) 87 | b, err := s.cli.Delete(s.tableName, d) 88 | c.Assert(err, IsNil) 89 | c.Assert(b, IsTrue) 90 | 91 | r, err = s.cli.Get(s.tableName, g) 92 | c.Assert(err, IsNil) 93 | c.Assert(r, IsNil) 94 | } 95 | -------------------------------------------------------------------------------- /get.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "strings" 5 | 6 | pb "github.com/golang/protobuf/proto" 7 | "github.com/juju/errors" 8 | "github.com/pingcap/go-hbase/proto" 9 | ) 10 | 11 | type Get struct { 12 | Row []byte 13 | Families set 14 | FamilyQuals map[string]set 15 | Versions int32 16 | TsRangeFrom uint64 17 | TsRangeTo uint64 18 | } 19 | 20 | func NewGet(row []byte) *Get { 21 | return &Get{ 22 | Row: append([]byte(nil), row...), 23 | Families: newSet(), 24 | FamilyQuals: make(map[string]set), 25 | Versions: 1, 26 | } 27 | } 28 | 29 | func (g *Get) GetRow() []byte { 30 | return g.Row 31 | } 32 | 33 | func (g *Get) AddString(famqual string) error { 34 | parts := strings.Split(famqual, ":") 35 | 36 | if len(parts) > 2 { 37 | return errors.Errorf("Too many colons were found in the family:qualifier string. '%s'", famqual) 38 | } else if len(parts) == 2 { 39 | g.AddStringColumn(parts[0], parts[1]) 40 | } else { 41 | g.AddStringFamily(famqual) 42 | } 43 | 44 | return nil 45 | } 46 | 47 | func (g *Get) AddColumn(family, qual []byte) *Get { 48 | g.AddFamily(family) 49 | g.FamilyQuals[string(family)].add(string(qual)) 50 | return g 51 | } 52 | 53 | func (g *Get) AddStringColumn(family, qual string) *Get { 54 | return g.AddColumn([]byte(family), []byte(qual)) 55 | } 56 | 57 | func (g *Get) AddFamily(family []byte) *Get { 58 | g.Families.add(string(family)) 59 | if _, ok := g.FamilyQuals[string(family)]; !ok { 60 | g.FamilyQuals[string(family)] = newSet() 61 | } 62 | return g 63 | } 64 | 65 | func (g *Get) AddStringFamily(family string) *Get { 66 | return g.AddFamily([]byte(family)) 67 | } 68 | 69 | func (g *Get) AddTimeRange(from uint64, to uint64) *Get { 70 | g.TsRangeFrom = from 71 | g.TsRangeTo = to 72 | return g 73 | } 74 | 75 | func (g *Get) SetMaxVersion(maxVersion int32) *Get { 76 | g.Versions = maxVersion 77 | return g 78 | } 79 | 80 | func (g *Get) ToProto() pb.Message { 81 | get := &proto.Get{ 82 | Row: g.Row, 83 | } 84 | 85 | if g.TsRangeFrom != 0 && g.TsRangeTo != 0 && g.TsRangeFrom <= g.TsRangeTo { 86 | get.TimeRange = &proto.TimeRange{ 87 | From: pb.Uint64(g.TsRangeFrom), 88 | To: pb.Uint64(g.TsRangeTo), 89 | } 90 | } 91 | 92 | for v := range g.Families { 93 | col := &proto.Column{ 94 | Family: []byte(v), 95 | } 96 | var quals [][]byte 97 | for qual := range g.FamilyQuals[v] { 98 | quals = append(quals, []byte(qual)) 99 | } 100 | col.Qualifier = quals 101 | get.Column = append(get.Column, col) 102 | } 103 | get.MaxVersions = pb.Uint32(uint32(g.Versions)) 104 | return get 105 | } 106 | -------------------------------------------------------------------------------- /get_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bytes" 5 | "runtime" 6 | "strconv" 7 | "sync" 8 | 9 | . "github.com/pingcap/check" 10 | "github.com/pingcap/go-hbase/proto" 11 | ) 12 | 13 | type HBaseGetTestSuit struct { 14 | cli HBaseClient 15 | tableName string 16 | } 17 | 18 | var _ = Suite(&HBaseGetTestSuit{}) 19 | 20 | func (s *HBaseGetTestSuit) SetUpTest(c *C) { 21 | var err error 22 | s.cli, err = NewClient(getTestZkHosts(), "/hbase") 23 | c.Assert(err, IsNil) 24 | 25 | s.tableName = "t1" 26 | tblDesc := NewTableDesciptor(s.tableName) 27 | cf := NewColumnFamilyDescriptor("cf") 28 | tblDesc.AddColumnDesc(cf) 29 | err = s.cli.CreateTable(tblDesc, nil) 30 | c.Assert(err, IsNil) 31 | } 32 | 33 | func (s *HBaseGetTestSuit) TearDownTest(c *C) { 34 | err := s.cli.DisableTable(s.tableName) 35 | c.Assert(err, IsNil) 36 | 37 | err = s.cli.DropTable(s.tableName) 38 | c.Assert(err, IsNil) 39 | } 40 | 41 | func (s *HBaseGetTestSuit) TestGet(c *C) { 42 | g := NewGet([]byte("row")) 43 | g.AddFamily([]byte("cf")) 44 | g.AddColumn([]byte("cf"), []byte("c")) 45 | g.AddColumn([]byte("cf"), []byte("v")) 46 | g.AddFamily([]byte("cf1")) 47 | 48 | msg := g.ToProto() 49 | p, _ := msg.(*proto.Get) 50 | 51 | c.Assert(p.Column, HasLen, 2) 52 | 53 | for _, col := range p.Column { 54 | if bytes.Compare([]byte("cf"), col.Family) == 0 { 55 | c.Assert(col.Qualifier, HasLen, 2) 56 | } else { 57 | c.Assert(col.Qualifier, HasLen, 0) 58 | } 59 | } 60 | } 61 | 62 | func (s *HBaseGetTestSuit) TestGetWithClient(c *C) { 63 | // get item not exists 64 | g := NewGet([]byte("nosuchrow")) 65 | r, err := s.cli.Get("nosuchtable", g) 66 | c.Assert(err, NotNil) 67 | c.Assert(r, IsNil) 68 | 69 | r, err = s.cli.Get("t1", g) 70 | c.Assert(r, IsNil) 71 | c.Assert(err, IsNil) 72 | } 73 | 74 | func (s *HBaseGetTestSuit) TestConcurrentGet(c *C) { 75 | runtime.GOMAXPROCS(runtime.NumCPU()) 76 | wg := sync.WaitGroup{} 77 | for i := 0; i < 100; i++ { 78 | wg.Add(1) 79 | go func(id int) { 80 | defer wg.Done() 81 | p := NewPut([]byte("test")) 82 | p.AddValue([]byte("cf"), []byte("q"), []byte(strconv.Itoa(i))) 83 | b, err := s.cli.Put(s.tableName, p) 84 | c.Assert(b, IsTrue) 85 | c.Assert(err, IsNil) 86 | }(i) 87 | } 88 | wg.Wait() 89 | 90 | g := NewGet([]byte("test")) 91 | _, err := s.cli.Get(s.tableName, g) 92 | c.Assert(err, IsNil) 93 | } 94 | -------------------------------------------------------------------------------- /iohelper/multireader.go: -------------------------------------------------------------------------------- 1 | package iohelper 2 | 3 | import "io" 4 | 5 | type ByteMultiReader interface { 6 | io.ByteReader 7 | io.Reader 8 | } 9 | -------------------------------------------------------------------------------- /iohelper/pbbuffer.go: -------------------------------------------------------------------------------- 1 | package iohelper 2 | 3 | import ( 4 | "encoding/binary" 5 | 6 | pb "github.com/golang/protobuf/proto" 7 | "github.com/juju/errors" 8 | ) 9 | 10 | type PbBuffer struct { 11 | b []byte 12 | } 13 | 14 | func NewPbBuffer() *PbBuffer { 15 | b := []byte{} 16 | return &PbBuffer{ 17 | b: b, 18 | } 19 | } 20 | 21 | func (b *PbBuffer) Bytes() []byte { 22 | return b.b 23 | } 24 | 25 | func (b *PbBuffer) Write(d []byte) (int, error) { 26 | b.b = append(b.b, d...) 27 | return len(d), nil 28 | } 29 | 30 | func (b *PbBuffer) WriteByte(d byte) error { 31 | return binary.Write(b, binary.BigEndian, d) 32 | } 33 | 34 | func (b *PbBuffer) WriteString(d string) error { 35 | return binary.Write(b, binary.BigEndian, d) 36 | } 37 | 38 | func (b *PbBuffer) WriteInt32(d int32) error { 39 | return binary.Write(b, binary.BigEndian, d) 40 | } 41 | 42 | func (b *PbBuffer) WriteInt64(d int64) error { 43 | return binary.Write(b, binary.BigEndian, d) 44 | } 45 | 46 | func (b *PbBuffer) WriteFloat32(d float32) error { 47 | return binary.Write(b, binary.BigEndian, d) 48 | } 49 | 50 | func (b *PbBuffer) WriteFloat64(d float64) error { 51 | return binary.Write(b, binary.BigEndian, d) 52 | } 53 | 54 | func (b *PbBuffer) WritePBMessage(d pb.Message) error { 55 | buf, err := pb.Marshal(d) 56 | if err != nil { 57 | return errors.Trace(err) 58 | } 59 | 60 | _, err = b.Write(buf) 61 | return errors.Trace(err) 62 | } 63 | 64 | func (b *PbBuffer) WriteDelimitedBuffers(bufs ...*PbBuffer) error { 65 | totalLength := 0 66 | lens := make([][]byte, len(bufs)) 67 | for i, v := range bufs { 68 | n := len(v.Bytes()) 69 | lenb := pb.EncodeVarint(uint64(n)) 70 | 71 | totalLength += len(lenb) + n 72 | lens[i] = lenb 73 | } 74 | 75 | err := b.WriteInt32(int32(totalLength)) 76 | if err != nil { 77 | return errors.Trace(err) 78 | } 79 | 80 | for i, v := range bufs { 81 | _, err = b.Write(lens[i]) 82 | if err != nil { 83 | return errors.Trace(err) 84 | } 85 | 86 | _, err = b.Write(v.Bytes()) 87 | if err != nil { 88 | return errors.Trace(err) 89 | } 90 | } 91 | 92 | return nil 93 | } 94 | 95 | func (b *PbBuffer) PrependSize() error { 96 | size := int32(len(b.b)) 97 | newBuf := NewPbBuffer() 98 | 99 | err := newBuf.WriteInt32(size) 100 | if err != nil { 101 | return errors.Trace(err) 102 | } 103 | 104 | _, err = newBuf.Write(b.b) 105 | if err != nil { 106 | return errors.Trace(err) 107 | } 108 | 109 | *b = *newBuf 110 | return nil 111 | } 112 | -------------------------------------------------------------------------------- /iohelper/utils.go: -------------------------------------------------------------------------------- 1 | package iohelper 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | "io" 7 | 8 | "github.com/juju/errors" 9 | ) 10 | 11 | var ( 12 | cachedItob [][]byte 13 | ) 14 | 15 | func init() { 16 | cachedItob = make([][]byte, 1024) 17 | for i := 0; i < len(cachedItob); i++ { 18 | var b bytes.Buffer 19 | writeVLong(&b, int64(i)) 20 | cachedItob[i] = b.Bytes() 21 | } 22 | } 23 | 24 | func itob(i int) ([]byte, error) { 25 | if i >= 0 && i < len(cachedItob) { 26 | return cachedItob[i], nil 27 | } 28 | 29 | var b bytes.Buffer 30 | err := binary.Write(&b, binary.BigEndian, i) 31 | if err != nil { 32 | return nil, errors.Trace(err) 33 | } 34 | return b.Bytes(), nil 35 | } 36 | 37 | func decodeVIntSize(value byte) int32 { 38 | if int32(value) >= -112 { 39 | return int32(1) 40 | } 41 | 42 | if int32(value) < -120 { 43 | return -119 - int32(value) 44 | } 45 | 46 | return -111 - int32(value) 47 | } 48 | 49 | func isNegativeVInt(value byte) bool { 50 | return int32(value) < -120 || int32(value) >= -112 && int32(value) < 0 51 | } 52 | 53 | func readVLong(r io.Reader) (int64, error) { 54 | var firstByte byte 55 | err := binary.Read(r, binary.BigEndian, &firstByte) 56 | if err != nil { 57 | return 0, errors.Trace(err) 58 | } 59 | 60 | l := decodeVIntSize(firstByte) 61 | if l == 1 { 62 | return int64(firstByte), nil 63 | } 64 | 65 | var ( 66 | i int64 67 | idx int32 68 | ) 69 | 70 | for idx = 0; idx < l-1; idx++ { 71 | var b byte 72 | err = binary.Read(r, binary.BigEndian, &b) 73 | if err != nil { 74 | return 0, errors.Trace(err) 75 | } 76 | 77 | i <<= 8 78 | i |= int64(b & 255) 79 | } 80 | 81 | if isNegativeVInt(firstByte) { 82 | return ^i, nil 83 | } 84 | 85 | return i, nil 86 | } 87 | 88 | func writeVLong(w io.Writer, i int64) error { 89 | var err error 90 | if i >= -112 && i <= 127 { 91 | err = binary.Write(w, binary.BigEndian, byte(i)) 92 | if err != nil { 93 | return errors.Trace(err) 94 | } 95 | } else { 96 | var l int32 = -112 97 | if i < 0 { 98 | i = ^i 99 | l = -120 100 | } 101 | var tmp int64 102 | for tmp = i; tmp != 0; l-- { 103 | tmp >>= 8 104 | } 105 | 106 | err = binary.Write(w, binary.BigEndian, byte(l)) 107 | if err != nil { 108 | return errors.Trace(err) 109 | } 110 | 111 | if l < -120 { 112 | l = -(l + 120) 113 | } else { 114 | l = -(l + 112) 115 | } 116 | 117 | for idx := l; idx != 0; idx-- { 118 | var mask int64 119 | shiftbits := uint((idx - 1) * 8) 120 | mask = int64(255) << shiftbits 121 | err = binary.Write(w, binary.BigEndian, byte((i&mask)>>shiftbits)) 122 | if err != nil { 123 | return errors.Trace(err) 124 | } 125 | } 126 | } 127 | 128 | return nil 129 | } 130 | 131 | func ReadVarBytes(r ByteMultiReader) ([]byte, error) { 132 | sz, err := readVLong(r) 133 | if err != nil { 134 | return nil, errors.Trace(err) 135 | } 136 | 137 | b := make([]byte, sz) 138 | _, err = r.Read(b) 139 | if err != nil { 140 | return nil, errors.Trace(err) 141 | } 142 | 143 | return b, nil 144 | } 145 | 146 | func WriteVarBytes(w io.Writer, b []byte) error { 147 | lenb, err := itob(len(b)) 148 | if err != nil { 149 | return errors.Trace(err) 150 | } 151 | 152 | _, err = w.Write(lenb) 153 | if err != nil { 154 | return errors.Trace(err) 155 | } 156 | 157 | _, err = w.Write(b) 158 | return errors.Trace(err) 159 | } 160 | 161 | func ReadInt32(r io.Reader) (int32, error) { 162 | var n int32 163 | err := binary.Read(r, binary.BigEndian, &n) 164 | return n, errors.Trace(err) 165 | } 166 | 167 | func ReadN(r io.Reader, n int32) ([]byte, error) { 168 | b := make([]byte, n) 169 | _, err := io.ReadFull(r, b) 170 | return b, errors.Trace(err) 171 | } 172 | 173 | func ReadUint64(r io.Reader) (uint64, error) { 174 | var n uint64 175 | err := binary.Read(r, binary.BigEndian, &n) 176 | return n, errors.Trace(err) 177 | } 178 | -------------------------------------------------------------------------------- /proto/Aggregate.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Aggregate.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type AggregateRequest struct { 15 | // * The request passed to the AggregateService consists of three parts 16 | // (1) the (canonical) classname of the ColumnInterpreter implementation 17 | // (2) the Scan query 18 | // (3) any bytes required to construct the ColumnInterpreter object 19 | // properly 20 | InterpreterClassName *string `protobuf:"bytes,1,req,name=interpreter_class_name" json:"interpreter_class_name,omitempty"` 21 | Scan *Scan `protobuf:"bytes,2,req,name=scan" json:"scan,omitempty"` 22 | InterpreterSpecificBytes []byte `protobuf:"bytes,3,opt,name=interpreter_specific_bytes" json:"interpreter_specific_bytes,omitempty"` 23 | XXX_unrecognized []byte `json:"-"` 24 | } 25 | 26 | func (m *AggregateRequest) Reset() { *m = AggregateRequest{} } 27 | func (m *AggregateRequest) String() string { return proto1.CompactTextString(m) } 28 | func (*AggregateRequest) ProtoMessage() {} 29 | 30 | func (m *AggregateRequest) GetInterpreterClassName() string { 31 | if m != nil && m.InterpreterClassName != nil { 32 | return *m.InterpreterClassName 33 | } 34 | return "" 35 | } 36 | 37 | func (m *AggregateRequest) GetScan() *Scan { 38 | if m != nil { 39 | return m.Scan 40 | } 41 | return nil 42 | } 43 | 44 | func (m *AggregateRequest) GetInterpreterSpecificBytes() []byte { 45 | if m != nil { 46 | return m.InterpreterSpecificBytes 47 | } 48 | return nil 49 | } 50 | 51 | type AggregateResponse struct { 52 | // * 53 | // The AggregateService methods all have a response that either is a Pair 54 | // or a simple object. When it is a Pair both first_part and second_part 55 | // have defined values (and the second_part is not present in the response 56 | // when the response is not a pair). Refer to the AggregateImplementation 57 | // class for an overview of the AggregateResponse object constructions. 58 | FirstPart [][]byte `protobuf:"bytes,1,rep,name=first_part" json:"first_part,omitempty"` 59 | SecondPart []byte `protobuf:"bytes,2,opt,name=second_part" json:"second_part,omitempty"` 60 | XXX_unrecognized []byte `json:"-"` 61 | } 62 | 63 | func (m *AggregateResponse) Reset() { *m = AggregateResponse{} } 64 | func (m *AggregateResponse) String() string { return proto1.CompactTextString(m) } 65 | func (*AggregateResponse) ProtoMessage() {} 66 | 67 | func (m *AggregateResponse) GetFirstPart() [][]byte { 68 | if m != nil { 69 | return m.FirstPart 70 | } 71 | return nil 72 | } 73 | 74 | func (m *AggregateResponse) GetSecondPart() []byte { 75 | if m != nil { 76 | return m.SecondPart 77 | } 78 | return nil 79 | } 80 | 81 | func init() { 82 | } 83 | -------------------------------------------------------------------------------- /proto/Authentication.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Authentication.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type TokenIdentifier_Kind int32 15 | 16 | const ( 17 | TokenIdentifier_HBASE_AUTH_TOKEN TokenIdentifier_Kind = 0 18 | ) 19 | 20 | var TokenIdentifier_Kind_name = map[int32]string{ 21 | 0: "HBASE_AUTH_TOKEN", 22 | } 23 | var TokenIdentifier_Kind_value = map[string]int32{ 24 | "HBASE_AUTH_TOKEN": 0, 25 | } 26 | 27 | func (x TokenIdentifier_Kind) Enum() *TokenIdentifier_Kind { 28 | p := new(TokenIdentifier_Kind) 29 | *p = x 30 | return p 31 | } 32 | func (x TokenIdentifier_Kind) String() string { 33 | return proto1.EnumName(TokenIdentifier_Kind_name, int32(x)) 34 | } 35 | func (x *TokenIdentifier_Kind) UnmarshalJSON(data []byte) error { 36 | value, err := proto1.UnmarshalJSONEnum(TokenIdentifier_Kind_value, data, "TokenIdentifier_Kind") 37 | if err != nil { 38 | return err 39 | } 40 | *x = TokenIdentifier_Kind(value) 41 | return nil 42 | } 43 | 44 | type AuthenticationKey struct { 45 | Id *int32 `protobuf:"varint,1,req,name=id" json:"id,omitempty"` 46 | ExpirationDate *int64 `protobuf:"varint,2,req,name=expiration_date" json:"expiration_date,omitempty"` 47 | Key []byte `protobuf:"bytes,3,req,name=key" json:"key,omitempty"` 48 | XXX_unrecognized []byte `json:"-"` 49 | } 50 | 51 | func (m *AuthenticationKey) Reset() { *m = AuthenticationKey{} } 52 | func (m *AuthenticationKey) String() string { return proto1.CompactTextString(m) } 53 | func (*AuthenticationKey) ProtoMessage() {} 54 | 55 | func (m *AuthenticationKey) GetId() int32 { 56 | if m != nil && m.Id != nil { 57 | return *m.Id 58 | } 59 | return 0 60 | } 61 | 62 | func (m *AuthenticationKey) GetExpirationDate() int64 { 63 | if m != nil && m.ExpirationDate != nil { 64 | return *m.ExpirationDate 65 | } 66 | return 0 67 | } 68 | 69 | func (m *AuthenticationKey) GetKey() []byte { 70 | if m != nil { 71 | return m.Key 72 | } 73 | return nil 74 | } 75 | 76 | type TokenIdentifier struct { 77 | Kind *TokenIdentifier_Kind `protobuf:"varint,1,req,name=kind,enum=proto.TokenIdentifier_Kind" json:"kind,omitempty"` 78 | Username []byte `protobuf:"bytes,2,req,name=username" json:"username,omitempty"` 79 | KeyId *int32 `protobuf:"varint,3,req,name=key_id" json:"key_id,omitempty"` 80 | IssueDate *int64 `protobuf:"varint,4,opt,name=issue_date" json:"issue_date,omitempty"` 81 | ExpirationDate *int64 `protobuf:"varint,5,opt,name=expiration_date" json:"expiration_date,omitempty"` 82 | SequenceNumber *int64 `protobuf:"varint,6,opt,name=sequence_number" json:"sequence_number,omitempty"` 83 | XXX_unrecognized []byte `json:"-"` 84 | } 85 | 86 | func (m *TokenIdentifier) Reset() { *m = TokenIdentifier{} } 87 | func (m *TokenIdentifier) String() string { return proto1.CompactTextString(m) } 88 | func (*TokenIdentifier) ProtoMessage() {} 89 | 90 | func (m *TokenIdentifier) GetKind() TokenIdentifier_Kind { 91 | if m != nil && m.Kind != nil { 92 | return *m.Kind 93 | } 94 | return TokenIdentifier_HBASE_AUTH_TOKEN 95 | } 96 | 97 | func (m *TokenIdentifier) GetUsername() []byte { 98 | if m != nil { 99 | return m.Username 100 | } 101 | return nil 102 | } 103 | 104 | func (m *TokenIdentifier) GetKeyId() int32 { 105 | if m != nil && m.KeyId != nil { 106 | return *m.KeyId 107 | } 108 | return 0 109 | } 110 | 111 | func (m *TokenIdentifier) GetIssueDate() int64 { 112 | if m != nil && m.IssueDate != nil { 113 | return *m.IssueDate 114 | } 115 | return 0 116 | } 117 | 118 | func (m *TokenIdentifier) GetExpirationDate() int64 { 119 | if m != nil && m.ExpirationDate != nil { 120 | return *m.ExpirationDate 121 | } 122 | return 0 123 | } 124 | 125 | func (m *TokenIdentifier) GetSequenceNumber() int64 { 126 | if m != nil && m.SequenceNumber != nil { 127 | return *m.SequenceNumber 128 | } 129 | return 0 130 | } 131 | 132 | // Serialization of the org.apache.hadoop.security.token.Token class 133 | // Note that this is a Hadoop class, so fields may change! 134 | type Token struct { 135 | // the TokenIdentifier in serialized form 136 | // Note: we can't use the protobuf directly because the Hadoop Token class 137 | // only stores the serialized bytes 138 | Identifier []byte `protobuf:"bytes,1,opt,name=identifier" json:"identifier,omitempty"` 139 | Password []byte `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"` 140 | Service []byte `protobuf:"bytes,3,opt,name=service" json:"service,omitempty"` 141 | XXX_unrecognized []byte `json:"-"` 142 | } 143 | 144 | func (m *Token) Reset() { *m = Token{} } 145 | func (m *Token) String() string { return proto1.CompactTextString(m) } 146 | func (*Token) ProtoMessage() {} 147 | 148 | func (m *Token) GetIdentifier() []byte { 149 | if m != nil { 150 | return m.Identifier 151 | } 152 | return nil 153 | } 154 | 155 | func (m *Token) GetPassword() []byte { 156 | if m != nil { 157 | return m.Password 158 | } 159 | return nil 160 | } 161 | 162 | func (m *Token) GetService() []byte { 163 | if m != nil { 164 | return m.Service 165 | } 166 | return nil 167 | } 168 | 169 | // RPC request & response messages 170 | type GetAuthenticationTokenRequest struct { 171 | XXX_unrecognized []byte `json:"-"` 172 | } 173 | 174 | func (m *GetAuthenticationTokenRequest) Reset() { *m = GetAuthenticationTokenRequest{} } 175 | func (m *GetAuthenticationTokenRequest) String() string { return proto1.CompactTextString(m) } 176 | func (*GetAuthenticationTokenRequest) ProtoMessage() {} 177 | 178 | type GetAuthenticationTokenResponse struct { 179 | Token *Token `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"` 180 | XXX_unrecognized []byte `json:"-"` 181 | } 182 | 183 | func (m *GetAuthenticationTokenResponse) Reset() { *m = GetAuthenticationTokenResponse{} } 184 | func (m *GetAuthenticationTokenResponse) String() string { return proto1.CompactTextString(m) } 185 | func (*GetAuthenticationTokenResponse) ProtoMessage() {} 186 | 187 | func (m *GetAuthenticationTokenResponse) GetToken() *Token { 188 | if m != nil { 189 | return m.Token 190 | } 191 | return nil 192 | } 193 | 194 | type WhoAmIRequest struct { 195 | XXX_unrecognized []byte `json:"-"` 196 | } 197 | 198 | func (m *WhoAmIRequest) Reset() { *m = WhoAmIRequest{} } 199 | func (m *WhoAmIRequest) String() string { return proto1.CompactTextString(m) } 200 | func (*WhoAmIRequest) ProtoMessage() {} 201 | 202 | type WhoAmIResponse struct { 203 | Username *string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"` 204 | AuthMethod *string `protobuf:"bytes,2,opt,name=auth_method" json:"auth_method,omitempty"` 205 | XXX_unrecognized []byte `json:"-"` 206 | } 207 | 208 | func (m *WhoAmIResponse) Reset() { *m = WhoAmIResponse{} } 209 | func (m *WhoAmIResponse) String() string { return proto1.CompactTextString(m) } 210 | func (*WhoAmIResponse) ProtoMessage() {} 211 | 212 | func (m *WhoAmIResponse) GetUsername() string { 213 | if m != nil && m.Username != nil { 214 | return *m.Username 215 | } 216 | return "" 217 | } 218 | 219 | func (m *WhoAmIResponse) GetAuthMethod() string { 220 | if m != nil && m.AuthMethod != nil { 221 | return *m.AuthMethod 222 | } 223 | return "" 224 | } 225 | 226 | func init() { 227 | proto1.RegisterEnum("proto.TokenIdentifier_Kind", TokenIdentifier_Kind_name, TokenIdentifier_Kind_value) 228 | } 229 | -------------------------------------------------------------------------------- /proto/Cell.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Cell.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | // * 15 | // The type of the key in a Cell 16 | type CellType int32 17 | 18 | const ( 19 | CellType_MINIMUM CellType = 0 20 | CellType_PUT CellType = 4 21 | CellType_DELETE CellType = 8 22 | CellType_DELETE_COLUMN CellType = 12 23 | CellType_DELETE_FAMILY CellType = 14 24 | // MAXIMUM is used when searching; you look from maximum on down. 25 | CellType_MAXIMUM CellType = 255 26 | ) 27 | 28 | var CellType_name = map[int32]string{ 29 | 0: "MINIMUM", 30 | 4: "PUT", 31 | 8: "DELETE", 32 | 12: "DELETE_COLUMN", 33 | 14: "DELETE_FAMILY", 34 | 255: "MAXIMUM", 35 | } 36 | var CellType_value = map[string]int32{ 37 | "MINIMUM": 0, 38 | "PUT": 4, 39 | "DELETE": 8, 40 | "DELETE_COLUMN": 12, 41 | "DELETE_FAMILY": 14, 42 | "MAXIMUM": 255, 43 | } 44 | 45 | func (x CellType) Enum() *CellType { 46 | p := new(CellType) 47 | *p = x 48 | return p 49 | } 50 | func (x CellType) String() string { 51 | return proto1.EnumName(CellType_name, int32(x)) 52 | } 53 | func (x *CellType) UnmarshalJSON(data []byte) error { 54 | value, err := proto1.UnmarshalJSONEnum(CellType_value, data, "CellType") 55 | if err != nil { 56 | return err 57 | } 58 | *x = CellType(value) 59 | return nil 60 | } 61 | 62 | // * 63 | // Protocol buffer version of Cell. 64 | type Cell struct { 65 | Row []byte `protobuf:"bytes,1,opt,name=row" json:"row,omitempty"` 66 | Family []byte `protobuf:"bytes,2,opt,name=family" json:"family,omitempty"` 67 | Qualifier []byte `protobuf:"bytes,3,opt,name=qualifier" json:"qualifier,omitempty"` 68 | Timestamp *uint64 `protobuf:"varint,4,opt,name=timestamp" json:"timestamp,omitempty"` 69 | CellType *CellType `protobuf:"varint,5,opt,name=cell_type,enum=proto.CellType" json:"cell_type,omitempty"` 70 | Value []byte `protobuf:"bytes,6,opt,name=value" json:"value,omitempty"` 71 | Tags []byte `protobuf:"bytes,7,opt,name=tags" json:"tags,omitempty"` 72 | XXX_unrecognized []byte `json:"-"` 73 | } 74 | 75 | func (m *Cell) Reset() { *m = Cell{} } 76 | func (m *Cell) String() string { return proto1.CompactTextString(m) } 77 | func (*Cell) ProtoMessage() {} 78 | 79 | func (m *Cell) GetRow() []byte { 80 | if m != nil { 81 | return m.Row 82 | } 83 | return nil 84 | } 85 | 86 | func (m *Cell) GetFamily() []byte { 87 | if m != nil { 88 | return m.Family 89 | } 90 | return nil 91 | } 92 | 93 | func (m *Cell) GetQualifier() []byte { 94 | if m != nil { 95 | return m.Qualifier 96 | } 97 | return nil 98 | } 99 | 100 | func (m *Cell) GetTimestamp() uint64 { 101 | if m != nil && m.Timestamp != nil { 102 | return *m.Timestamp 103 | } 104 | return 0 105 | } 106 | 107 | func (m *Cell) GetCellType() CellType { 108 | if m != nil && m.CellType != nil { 109 | return *m.CellType 110 | } 111 | return CellType_MINIMUM 112 | } 113 | 114 | func (m *Cell) GetValue() []byte { 115 | if m != nil { 116 | return m.Value 117 | } 118 | return nil 119 | } 120 | 121 | func (m *Cell) GetTags() []byte { 122 | if m != nil { 123 | return m.Tags 124 | } 125 | return nil 126 | } 127 | 128 | // * 129 | // Protocol buffer version of KeyValue. 130 | // It doesn't have those transient parameters 131 | type KeyValue struct { 132 | Row []byte `protobuf:"bytes,1,req,name=row" json:"row,omitempty"` 133 | Family []byte `protobuf:"bytes,2,req,name=family" json:"family,omitempty"` 134 | Qualifier []byte `protobuf:"bytes,3,req,name=qualifier" json:"qualifier,omitempty"` 135 | Timestamp *uint64 `protobuf:"varint,4,opt,name=timestamp" json:"timestamp,omitempty"` 136 | KeyType *CellType `protobuf:"varint,5,opt,name=key_type,enum=proto.CellType" json:"key_type,omitempty"` 137 | Value []byte `protobuf:"bytes,6,opt,name=value" json:"value,omitempty"` 138 | Tags []byte `protobuf:"bytes,7,opt,name=tags" json:"tags,omitempty"` 139 | XXX_unrecognized []byte `json:"-"` 140 | } 141 | 142 | func (m *KeyValue) Reset() { *m = KeyValue{} } 143 | func (m *KeyValue) String() string { return proto1.CompactTextString(m) } 144 | func (*KeyValue) ProtoMessage() {} 145 | 146 | func (m *KeyValue) GetRow() []byte { 147 | if m != nil { 148 | return m.Row 149 | } 150 | return nil 151 | } 152 | 153 | func (m *KeyValue) GetFamily() []byte { 154 | if m != nil { 155 | return m.Family 156 | } 157 | return nil 158 | } 159 | 160 | func (m *KeyValue) GetQualifier() []byte { 161 | if m != nil { 162 | return m.Qualifier 163 | } 164 | return nil 165 | } 166 | 167 | func (m *KeyValue) GetTimestamp() uint64 { 168 | if m != nil && m.Timestamp != nil { 169 | return *m.Timestamp 170 | } 171 | return 0 172 | } 173 | 174 | func (m *KeyValue) GetKeyType() CellType { 175 | if m != nil && m.KeyType != nil { 176 | return *m.KeyType 177 | } 178 | return CellType_MINIMUM 179 | } 180 | 181 | func (m *KeyValue) GetValue() []byte { 182 | if m != nil { 183 | return m.Value 184 | } 185 | return nil 186 | } 187 | 188 | func (m *KeyValue) GetTags() []byte { 189 | if m != nil { 190 | return m.Tags 191 | } 192 | return nil 193 | } 194 | 195 | func init() { 196 | proto1.RegisterEnum("proto.CellType", CellType_name, CellType_value) 197 | } 198 | -------------------------------------------------------------------------------- /proto/ClusterId.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: ClusterId.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | // * 15 | // Content of the '/hbase/hbaseid', cluster id, znode. 16 | // Also cluster of the ${HBASE_ROOTDIR}/hbase.id file. 17 | type ClusterId struct { 18 | // This is the cluster id, a uuid as a String 19 | ClusterId *string `protobuf:"bytes,1,req,name=cluster_id" json:"cluster_id,omitempty"` 20 | XXX_unrecognized []byte `json:"-"` 21 | } 22 | 23 | func (m *ClusterId) Reset() { *m = ClusterId{} } 24 | func (m *ClusterId) String() string { return proto1.CompactTextString(m) } 25 | func (*ClusterId) ProtoMessage() {} 26 | 27 | func (m *ClusterId) GetClusterId() string { 28 | if m != nil && m.ClusterId != nil { 29 | return *m.ClusterId 30 | } 31 | return "" 32 | } 33 | 34 | func init() { 35 | } 36 | -------------------------------------------------------------------------------- /proto/Comparator.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Comparator.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type BitComparator_BitwiseOp int32 15 | 16 | const ( 17 | BitComparator_AND BitComparator_BitwiseOp = 1 18 | BitComparator_OR BitComparator_BitwiseOp = 2 19 | BitComparator_XOR BitComparator_BitwiseOp = 3 20 | ) 21 | 22 | var BitComparator_BitwiseOp_name = map[int32]string{ 23 | 1: "AND", 24 | 2: "OR", 25 | 3: "XOR", 26 | } 27 | var BitComparator_BitwiseOp_value = map[string]int32{ 28 | "AND": 1, 29 | "OR": 2, 30 | "XOR": 3, 31 | } 32 | 33 | func (x BitComparator_BitwiseOp) Enum() *BitComparator_BitwiseOp { 34 | p := new(BitComparator_BitwiseOp) 35 | *p = x 36 | return p 37 | } 38 | func (x BitComparator_BitwiseOp) String() string { 39 | return proto1.EnumName(BitComparator_BitwiseOp_name, int32(x)) 40 | } 41 | func (x *BitComparator_BitwiseOp) UnmarshalJSON(data []byte) error { 42 | value, err := proto1.UnmarshalJSONEnum(BitComparator_BitwiseOp_value, data, "BitComparator_BitwiseOp") 43 | if err != nil { 44 | return err 45 | } 46 | *x = BitComparator_BitwiseOp(value) 47 | return nil 48 | } 49 | 50 | type Comparator struct { 51 | Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` 52 | SerializedComparator []byte `protobuf:"bytes,2,opt,name=serialized_comparator" json:"serialized_comparator,omitempty"` 53 | XXX_unrecognized []byte `json:"-"` 54 | } 55 | 56 | func (m *Comparator) Reset() { *m = Comparator{} } 57 | func (m *Comparator) String() string { return proto1.CompactTextString(m) } 58 | func (*Comparator) ProtoMessage() {} 59 | 60 | func (m *Comparator) GetName() string { 61 | if m != nil && m.Name != nil { 62 | return *m.Name 63 | } 64 | return "" 65 | } 66 | 67 | func (m *Comparator) GetSerializedComparator() []byte { 68 | if m != nil { 69 | return m.SerializedComparator 70 | } 71 | return nil 72 | } 73 | 74 | type ByteArrayComparable struct { 75 | Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` 76 | XXX_unrecognized []byte `json:"-"` 77 | } 78 | 79 | func (m *ByteArrayComparable) Reset() { *m = ByteArrayComparable{} } 80 | func (m *ByteArrayComparable) String() string { return proto1.CompactTextString(m) } 81 | func (*ByteArrayComparable) ProtoMessage() {} 82 | 83 | func (m *ByteArrayComparable) GetValue() []byte { 84 | if m != nil { 85 | return m.Value 86 | } 87 | return nil 88 | } 89 | 90 | type BinaryComparator struct { 91 | Comparable *ByteArrayComparable `protobuf:"bytes,1,req,name=comparable" json:"comparable,omitempty"` 92 | XXX_unrecognized []byte `json:"-"` 93 | } 94 | 95 | func (m *BinaryComparator) Reset() { *m = BinaryComparator{} } 96 | func (m *BinaryComparator) String() string { return proto1.CompactTextString(m) } 97 | func (*BinaryComparator) ProtoMessage() {} 98 | 99 | func (m *BinaryComparator) GetComparable() *ByteArrayComparable { 100 | if m != nil { 101 | return m.Comparable 102 | } 103 | return nil 104 | } 105 | 106 | type LongComparator struct { 107 | Comparable *ByteArrayComparable `protobuf:"bytes,1,req,name=comparable" json:"comparable,omitempty"` 108 | XXX_unrecognized []byte `json:"-"` 109 | } 110 | 111 | func (m *LongComparator) Reset() { *m = LongComparator{} } 112 | func (m *LongComparator) String() string { return proto1.CompactTextString(m) } 113 | func (*LongComparator) ProtoMessage() {} 114 | 115 | func (m *LongComparator) GetComparable() *ByteArrayComparable { 116 | if m != nil { 117 | return m.Comparable 118 | } 119 | return nil 120 | } 121 | 122 | type BinaryPrefixComparator struct { 123 | Comparable *ByteArrayComparable `protobuf:"bytes,1,req,name=comparable" json:"comparable,omitempty"` 124 | XXX_unrecognized []byte `json:"-"` 125 | } 126 | 127 | func (m *BinaryPrefixComparator) Reset() { *m = BinaryPrefixComparator{} } 128 | func (m *BinaryPrefixComparator) String() string { return proto1.CompactTextString(m) } 129 | func (*BinaryPrefixComparator) ProtoMessage() {} 130 | 131 | func (m *BinaryPrefixComparator) GetComparable() *ByteArrayComparable { 132 | if m != nil { 133 | return m.Comparable 134 | } 135 | return nil 136 | } 137 | 138 | type BitComparator struct { 139 | Comparable *ByteArrayComparable `protobuf:"bytes,1,req,name=comparable" json:"comparable,omitempty"` 140 | BitwiseOp *BitComparator_BitwiseOp `protobuf:"varint,2,req,name=bitwise_op,enum=proto.BitComparator_BitwiseOp" json:"bitwise_op,omitempty"` 141 | XXX_unrecognized []byte `json:"-"` 142 | } 143 | 144 | func (m *BitComparator) Reset() { *m = BitComparator{} } 145 | func (m *BitComparator) String() string { return proto1.CompactTextString(m) } 146 | func (*BitComparator) ProtoMessage() {} 147 | 148 | func (m *BitComparator) GetComparable() *ByteArrayComparable { 149 | if m != nil { 150 | return m.Comparable 151 | } 152 | return nil 153 | } 154 | 155 | func (m *BitComparator) GetBitwiseOp() BitComparator_BitwiseOp { 156 | if m != nil && m.BitwiseOp != nil { 157 | return *m.BitwiseOp 158 | } 159 | return BitComparator_AND 160 | } 161 | 162 | type NullComparator struct { 163 | XXX_unrecognized []byte `json:"-"` 164 | } 165 | 166 | func (m *NullComparator) Reset() { *m = NullComparator{} } 167 | func (m *NullComparator) String() string { return proto1.CompactTextString(m) } 168 | func (*NullComparator) ProtoMessage() {} 169 | 170 | type RegexStringComparator struct { 171 | Pattern *string `protobuf:"bytes,1,req,name=pattern" json:"pattern,omitempty"` 172 | PatternFlags *int32 `protobuf:"varint,2,req,name=pattern_flags" json:"pattern_flags,omitempty"` 173 | Charset *string `protobuf:"bytes,3,req,name=charset" json:"charset,omitempty"` 174 | Engine *string `protobuf:"bytes,4,opt,name=engine" json:"engine,omitempty"` 175 | XXX_unrecognized []byte `json:"-"` 176 | } 177 | 178 | func (m *RegexStringComparator) Reset() { *m = RegexStringComparator{} } 179 | func (m *RegexStringComparator) String() string { return proto1.CompactTextString(m) } 180 | func (*RegexStringComparator) ProtoMessage() {} 181 | 182 | func (m *RegexStringComparator) GetPattern() string { 183 | if m != nil && m.Pattern != nil { 184 | return *m.Pattern 185 | } 186 | return "" 187 | } 188 | 189 | func (m *RegexStringComparator) GetPatternFlags() int32 { 190 | if m != nil && m.PatternFlags != nil { 191 | return *m.PatternFlags 192 | } 193 | return 0 194 | } 195 | 196 | func (m *RegexStringComparator) GetCharset() string { 197 | if m != nil && m.Charset != nil { 198 | return *m.Charset 199 | } 200 | return "" 201 | } 202 | 203 | func (m *RegexStringComparator) GetEngine() string { 204 | if m != nil && m.Engine != nil { 205 | return *m.Engine 206 | } 207 | return "" 208 | } 209 | 210 | type SubstringComparator struct { 211 | Substr *string `protobuf:"bytes,1,req,name=substr" json:"substr,omitempty"` 212 | XXX_unrecognized []byte `json:"-"` 213 | } 214 | 215 | func (m *SubstringComparator) Reset() { *m = SubstringComparator{} } 216 | func (m *SubstringComparator) String() string { return proto1.CompactTextString(m) } 217 | func (*SubstringComparator) ProtoMessage() {} 218 | 219 | func (m *SubstringComparator) GetSubstr() string { 220 | if m != nil && m.Substr != nil { 221 | return *m.Substr 222 | } 223 | return "" 224 | } 225 | 226 | func init() { 227 | proto1.RegisterEnum("proto.BitComparator_BitwiseOp", BitComparator_BitwiseOp_name, BitComparator_BitwiseOp_value) 228 | } 229 | -------------------------------------------------------------------------------- /proto/Encryption.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Encryption.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type WrappedKey struct { 15 | Algorithm *string `protobuf:"bytes,1,req,name=algorithm" json:"algorithm,omitempty"` 16 | Length *uint32 `protobuf:"varint,2,req,name=length" json:"length,omitempty"` 17 | Data []byte `protobuf:"bytes,3,req,name=data" json:"data,omitempty"` 18 | Iv []byte `protobuf:"bytes,4,opt,name=iv" json:"iv,omitempty"` 19 | Hash []byte `protobuf:"bytes,5,opt,name=hash" json:"hash,omitempty"` 20 | XXX_unrecognized []byte `json:"-"` 21 | } 22 | 23 | func (m *WrappedKey) Reset() { *m = WrappedKey{} } 24 | func (m *WrappedKey) String() string { return proto1.CompactTextString(m) } 25 | func (*WrappedKey) ProtoMessage() {} 26 | 27 | func (m *WrappedKey) GetAlgorithm() string { 28 | if m != nil && m.Algorithm != nil { 29 | return *m.Algorithm 30 | } 31 | return "" 32 | } 33 | 34 | func (m *WrappedKey) GetLength() uint32 { 35 | if m != nil && m.Length != nil { 36 | return *m.Length 37 | } 38 | return 0 39 | } 40 | 41 | func (m *WrappedKey) GetData() []byte { 42 | if m != nil { 43 | return m.Data 44 | } 45 | return nil 46 | } 47 | 48 | func (m *WrappedKey) GetIv() []byte { 49 | if m != nil { 50 | return m.Iv 51 | } 52 | return nil 53 | } 54 | 55 | func (m *WrappedKey) GetHash() []byte { 56 | if m != nil { 57 | return m.Hash 58 | } 59 | return nil 60 | } 61 | 62 | func init() { 63 | } 64 | -------------------------------------------------------------------------------- /proto/ErrorHandling.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: ErrorHandling.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | // * 15 | // Protobuf version of a java.lang.StackTraceElement 16 | // so we can serialize exceptions. 17 | type StackTraceElementMessage struct { 18 | DeclaringClass *string `protobuf:"bytes,1,opt,name=declaring_class" json:"declaring_class,omitempty"` 19 | MethodName *string `protobuf:"bytes,2,opt,name=method_name" json:"method_name,omitempty"` 20 | FileName *string `protobuf:"bytes,3,opt,name=file_name" json:"file_name,omitempty"` 21 | LineNumber *int32 `protobuf:"varint,4,opt,name=line_number" json:"line_number,omitempty"` 22 | XXX_unrecognized []byte `json:"-"` 23 | } 24 | 25 | func (m *StackTraceElementMessage) Reset() { *m = StackTraceElementMessage{} } 26 | func (m *StackTraceElementMessage) String() string { return proto1.CompactTextString(m) } 27 | func (*StackTraceElementMessage) ProtoMessage() {} 28 | 29 | func (m *StackTraceElementMessage) GetDeclaringClass() string { 30 | if m != nil && m.DeclaringClass != nil { 31 | return *m.DeclaringClass 32 | } 33 | return "" 34 | } 35 | 36 | func (m *StackTraceElementMessage) GetMethodName() string { 37 | if m != nil && m.MethodName != nil { 38 | return *m.MethodName 39 | } 40 | return "" 41 | } 42 | 43 | func (m *StackTraceElementMessage) GetFileName() string { 44 | if m != nil && m.FileName != nil { 45 | return *m.FileName 46 | } 47 | return "" 48 | } 49 | 50 | func (m *StackTraceElementMessage) GetLineNumber() int32 { 51 | if m != nil && m.LineNumber != nil { 52 | return *m.LineNumber 53 | } 54 | return 0 55 | } 56 | 57 | // * 58 | // Cause of a remote failure for a generic exception. Contains 59 | // all the information for a generic exception as well as 60 | // optional info about the error for generic info passing 61 | // (which should be another protobuffed class). 62 | type GenericExceptionMessage struct { 63 | ClassName *string `protobuf:"bytes,1,opt,name=class_name" json:"class_name,omitempty"` 64 | Message *string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` 65 | ErrorInfo []byte `protobuf:"bytes,3,opt,name=error_info" json:"error_info,omitempty"` 66 | Trace []*StackTraceElementMessage `protobuf:"bytes,4,rep,name=trace" json:"trace,omitempty"` 67 | XXX_unrecognized []byte `json:"-"` 68 | } 69 | 70 | func (m *GenericExceptionMessage) Reset() { *m = GenericExceptionMessage{} } 71 | func (m *GenericExceptionMessage) String() string { return proto1.CompactTextString(m) } 72 | func (*GenericExceptionMessage) ProtoMessage() {} 73 | 74 | func (m *GenericExceptionMessage) GetClassName() string { 75 | if m != nil && m.ClassName != nil { 76 | return *m.ClassName 77 | } 78 | return "" 79 | } 80 | 81 | func (m *GenericExceptionMessage) GetMessage() string { 82 | if m != nil && m.Message != nil { 83 | return *m.Message 84 | } 85 | return "" 86 | } 87 | 88 | func (m *GenericExceptionMessage) GetErrorInfo() []byte { 89 | if m != nil { 90 | return m.ErrorInfo 91 | } 92 | return nil 93 | } 94 | 95 | func (m *GenericExceptionMessage) GetTrace() []*StackTraceElementMessage { 96 | if m != nil { 97 | return m.Trace 98 | } 99 | return nil 100 | } 101 | 102 | // * 103 | // Exception sent across the wire when a remote task needs 104 | // to notify other tasks that it failed and why 105 | type ForeignExceptionMessage struct { 106 | Source *string `protobuf:"bytes,1,opt,name=source" json:"source,omitempty"` 107 | GenericException *GenericExceptionMessage `protobuf:"bytes,2,opt,name=generic_exception" json:"generic_exception,omitempty"` 108 | XXX_unrecognized []byte `json:"-"` 109 | } 110 | 111 | func (m *ForeignExceptionMessage) Reset() { *m = ForeignExceptionMessage{} } 112 | func (m *ForeignExceptionMessage) String() string { return proto1.CompactTextString(m) } 113 | func (*ForeignExceptionMessage) ProtoMessage() {} 114 | 115 | func (m *ForeignExceptionMessage) GetSource() string { 116 | if m != nil && m.Source != nil { 117 | return *m.Source 118 | } 119 | return "" 120 | } 121 | 122 | func (m *ForeignExceptionMessage) GetGenericException() *GenericExceptionMessage { 123 | if m != nil { 124 | return m.GenericException 125 | } 126 | return nil 127 | } 128 | 129 | func init() { 130 | } 131 | -------------------------------------------------------------------------------- /proto/FS.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: FS.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type Reference_Range int32 15 | 16 | const ( 17 | Reference_TOP Reference_Range = 0 18 | Reference_BOTTOM Reference_Range = 1 19 | ) 20 | 21 | var Reference_Range_name = map[int32]string{ 22 | 0: "TOP", 23 | 1: "BOTTOM", 24 | } 25 | var Reference_Range_value = map[string]int32{ 26 | "TOP": 0, 27 | "BOTTOM": 1, 28 | } 29 | 30 | func (x Reference_Range) Enum() *Reference_Range { 31 | p := new(Reference_Range) 32 | *p = x 33 | return p 34 | } 35 | func (x Reference_Range) String() string { 36 | return proto1.EnumName(Reference_Range_name, int32(x)) 37 | } 38 | func (x *Reference_Range) UnmarshalJSON(data []byte) error { 39 | value, err := proto1.UnmarshalJSONEnum(Reference_Range_value, data, "Reference_Range") 40 | if err != nil { 41 | return err 42 | } 43 | *x = Reference_Range(value) 44 | return nil 45 | } 46 | 47 | // * 48 | // The ${HBASE_ROOTDIR}/hbase.version file content 49 | type HBaseVersionFileContent struct { 50 | Version *string `protobuf:"bytes,1,req,name=version" json:"version,omitempty"` 51 | XXX_unrecognized []byte `json:"-"` 52 | } 53 | 54 | func (m *HBaseVersionFileContent) Reset() { *m = HBaseVersionFileContent{} } 55 | func (m *HBaseVersionFileContent) String() string { return proto1.CompactTextString(m) } 56 | func (*HBaseVersionFileContent) ProtoMessage() {} 57 | 58 | func (m *HBaseVersionFileContent) GetVersion() string { 59 | if m != nil && m.Version != nil { 60 | return *m.Version 61 | } 62 | return "" 63 | } 64 | 65 | // * 66 | // Reference file content used when we split an hfile under a region. 67 | type Reference struct { 68 | Splitkey []byte `protobuf:"bytes,1,req,name=splitkey" json:"splitkey,omitempty"` 69 | Range *Reference_Range `protobuf:"varint,2,req,name=range,enum=proto.Reference_Range" json:"range,omitempty"` 70 | XXX_unrecognized []byte `json:"-"` 71 | } 72 | 73 | func (m *Reference) Reset() { *m = Reference{} } 74 | func (m *Reference) String() string { return proto1.CompactTextString(m) } 75 | func (*Reference) ProtoMessage() {} 76 | 77 | func (m *Reference) GetSplitkey() []byte { 78 | if m != nil { 79 | return m.Splitkey 80 | } 81 | return nil 82 | } 83 | 84 | func (m *Reference) GetRange() Reference_Range { 85 | if m != nil && m.Range != nil { 86 | return *m.Range 87 | } 88 | return Reference_TOP 89 | } 90 | 91 | func init() { 92 | proto1.RegisterEnum("proto.Reference_Range", Reference_Range_name, Reference_Range_value) 93 | } 94 | -------------------------------------------------------------------------------- /proto/HFile.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: HFile.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | // Map of name/values 15 | type FileInfoProto struct { 16 | MapEntry []*BytesBytesPair `protobuf:"bytes,1,rep,name=map_entry" json:"map_entry,omitempty"` 17 | XXX_unrecognized []byte `json:"-"` 18 | } 19 | 20 | func (m *FileInfoProto) Reset() { *m = FileInfoProto{} } 21 | func (m *FileInfoProto) String() string { return proto1.CompactTextString(m) } 22 | func (*FileInfoProto) ProtoMessage() {} 23 | 24 | func (m *FileInfoProto) GetMapEntry() []*BytesBytesPair { 25 | if m != nil { 26 | return m.MapEntry 27 | } 28 | return nil 29 | } 30 | 31 | // HFile file trailer 32 | type FileTrailerProto struct { 33 | FileInfoOffset *uint64 `protobuf:"varint,1,opt,name=file_info_offset" json:"file_info_offset,omitempty"` 34 | LoadOnOpenDataOffset *uint64 `protobuf:"varint,2,opt,name=load_on_open_data_offset" json:"load_on_open_data_offset,omitempty"` 35 | UncompressedDataIndexSize *uint64 `protobuf:"varint,3,opt,name=uncompressed_data_index_size" json:"uncompressed_data_index_size,omitempty"` 36 | TotalUncompressedBytes *uint64 `protobuf:"varint,4,opt,name=total_uncompressed_bytes" json:"total_uncompressed_bytes,omitempty"` 37 | DataIndexCount *uint32 `protobuf:"varint,5,opt,name=data_index_count" json:"data_index_count,omitempty"` 38 | MetaIndexCount *uint32 `protobuf:"varint,6,opt,name=meta_index_count" json:"meta_index_count,omitempty"` 39 | EntryCount *uint64 `protobuf:"varint,7,opt,name=entry_count" json:"entry_count,omitempty"` 40 | NumDataIndexLevels *uint32 `protobuf:"varint,8,opt,name=num_data_index_levels" json:"num_data_index_levels,omitempty"` 41 | FirstDataBlockOffset *uint64 `protobuf:"varint,9,opt,name=first_data_block_offset" json:"first_data_block_offset,omitempty"` 42 | LastDataBlockOffset *uint64 `protobuf:"varint,10,opt,name=last_data_block_offset" json:"last_data_block_offset,omitempty"` 43 | ComparatorClassName *string `protobuf:"bytes,11,opt,name=comparator_class_name" json:"comparator_class_name,omitempty"` 44 | CompressionCodec *uint32 `protobuf:"varint,12,opt,name=compression_codec" json:"compression_codec,omitempty"` 45 | EncryptionKey []byte `protobuf:"bytes,13,opt,name=encryption_key" json:"encryption_key,omitempty"` 46 | XXX_unrecognized []byte `json:"-"` 47 | } 48 | 49 | func (m *FileTrailerProto) Reset() { *m = FileTrailerProto{} } 50 | func (m *FileTrailerProto) String() string { return proto1.CompactTextString(m) } 51 | func (*FileTrailerProto) ProtoMessage() {} 52 | 53 | func (m *FileTrailerProto) GetFileInfoOffset() uint64 { 54 | if m != nil && m.FileInfoOffset != nil { 55 | return *m.FileInfoOffset 56 | } 57 | return 0 58 | } 59 | 60 | func (m *FileTrailerProto) GetLoadOnOpenDataOffset() uint64 { 61 | if m != nil && m.LoadOnOpenDataOffset != nil { 62 | return *m.LoadOnOpenDataOffset 63 | } 64 | return 0 65 | } 66 | 67 | func (m *FileTrailerProto) GetUncompressedDataIndexSize() uint64 { 68 | if m != nil && m.UncompressedDataIndexSize != nil { 69 | return *m.UncompressedDataIndexSize 70 | } 71 | return 0 72 | } 73 | 74 | func (m *FileTrailerProto) GetTotalUncompressedBytes() uint64 { 75 | if m != nil && m.TotalUncompressedBytes != nil { 76 | return *m.TotalUncompressedBytes 77 | } 78 | return 0 79 | } 80 | 81 | func (m *FileTrailerProto) GetDataIndexCount() uint32 { 82 | if m != nil && m.DataIndexCount != nil { 83 | return *m.DataIndexCount 84 | } 85 | return 0 86 | } 87 | 88 | func (m *FileTrailerProto) GetMetaIndexCount() uint32 { 89 | if m != nil && m.MetaIndexCount != nil { 90 | return *m.MetaIndexCount 91 | } 92 | return 0 93 | } 94 | 95 | func (m *FileTrailerProto) GetEntryCount() uint64 { 96 | if m != nil && m.EntryCount != nil { 97 | return *m.EntryCount 98 | } 99 | return 0 100 | } 101 | 102 | func (m *FileTrailerProto) GetNumDataIndexLevels() uint32 { 103 | if m != nil && m.NumDataIndexLevels != nil { 104 | return *m.NumDataIndexLevels 105 | } 106 | return 0 107 | } 108 | 109 | func (m *FileTrailerProto) GetFirstDataBlockOffset() uint64 { 110 | if m != nil && m.FirstDataBlockOffset != nil { 111 | return *m.FirstDataBlockOffset 112 | } 113 | return 0 114 | } 115 | 116 | func (m *FileTrailerProto) GetLastDataBlockOffset() uint64 { 117 | if m != nil && m.LastDataBlockOffset != nil { 118 | return *m.LastDataBlockOffset 119 | } 120 | return 0 121 | } 122 | 123 | func (m *FileTrailerProto) GetComparatorClassName() string { 124 | if m != nil && m.ComparatorClassName != nil { 125 | return *m.ComparatorClassName 126 | } 127 | return "" 128 | } 129 | 130 | func (m *FileTrailerProto) GetCompressionCodec() uint32 { 131 | if m != nil && m.CompressionCodec != nil { 132 | return *m.CompressionCodec 133 | } 134 | return 0 135 | } 136 | 137 | func (m *FileTrailerProto) GetEncryptionKey() []byte { 138 | if m != nil { 139 | return m.EncryptionKey 140 | } 141 | return nil 142 | } 143 | 144 | func init() { 145 | } 146 | -------------------------------------------------------------------------------- /proto/LoadBalancer.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: LoadBalancer.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type LoadBalancerState struct { 15 | BalancerOn *bool `protobuf:"varint,1,opt,name=balancer_on" json:"balancer_on,omitempty"` 16 | XXX_unrecognized []byte `json:"-"` 17 | } 18 | 19 | func (m *LoadBalancerState) Reset() { *m = LoadBalancerState{} } 20 | func (m *LoadBalancerState) String() string { return proto1.CompactTextString(m) } 21 | func (*LoadBalancerState) ProtoMessage() {} 22 | 23 | func (m *LoadBalancerState) GetBalancerOn() bool { 24 | if m != nil && m.BalancerOn != nil { 25 | return *m.BalancerOn 26 | } 27 | return false 28 | } 29 | 30 | func init() { 31 | } 32 | -------------------------------------------------------------------------------- /proto/MapReduce.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: MapReduce.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type ScanMetrics struct { 15 | Metrics []*NameInt64Pair `protobuf:"bytes,1,rep,name=metrics" json:"metrics,omitempty"` 16 | XXX_unrecognized []byte `json:"-"` 17 | } 18 | 19 | func (m *ScanMetrics) Reset() { *m = ScanMetrics{} } 20 | func (m *ScanMetrics) String() string { return proto1.CompactTextString(m) } 21 | func (*ScanMetrics) ProtoMessage() {} 22 | 23 | func (m *ScanMetrics) GetMetrics() []*NameInt64Pair { 24 | if m != nil { 25 | return m.Metrics 26 | } 27 | return nil 28 | } 29 | 30 | type TableSnapshotRegionSplit struct { 31 | Locations []string `protobuf:"bytes,2,rep,name=locations" json:"locations,omitempty"` 32 | Table *TableSchema `protobuf:"bytes,3,opt,name=table" json:"table,omitempty"` 33 | Region *RegionInfo `protobuf:"bytes,4,opt,name=region" json:"region,omitempty"` 34 | XXX_unrecognized []byte `json:"-"` 35 | } 36 | 37 | func (m *TableSnapshotRegionSplit) Reset() { *m = TableSnapshotRegionSplit{} } 38 | func (m *TableSnapshotRegionSplit) String() string { return proto1.CompactTextString(m) } 39 | func (*TableSnapshotRegionSplit) ProtoMessage() {} 40 | 41 | func (m *TableSnapshotRegionSplit) GetLocations() []string { 42 | if m != nil { 43 | return m.Locations 44 | } 45 | return nil 46 | } 47 | 48 | func (m *TableSnapshotRegionSplit) GetTable() *TableSchema { 49 | if m != nil { 50 | return m.Table 51 | } 52 | return nil 53 | } 54 | 55 | func (m *TableSnapshotRegionSplit) GetRegion() *RegionInfo { 56 | if m != nil { 57 | return m.Region 58 | } 59 | return nil 60 | } 61 | 62 | func init() { 63 | } 64 | -------------------------------------------------------------------------------- /proto/MultiRowMutation.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: MultiRowMutation.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type MultiRowMutationProcessorRequest struct { 15 | XXX_unrecognized []byte `json:"-"` 16 | } 17 | 18 | func (m *MultiRowMutationProcessorRequest) Reset() { *m = MultiRowMutationProcessorRequest{} } 19 | func (m *MultiRowMutationProcessorRequest) String() string { return proto1.CompactTextString(m) } 20 | func (*MultiRowMutationProcessorRequest) ProtoMessage() {} 21 | 22 | type MultiRowMutationProcessorResponse struct { 23 | XXX_unrecognized []byte `json:"-"` 24 | } 25 | 26 | func (m *MultiRowMutationProcessorResponse) Reset() { *m = MultiRowMutationProcessorResponse{} } 27 | func (m *MultiRowMutationProcessorResponse) String() string { return proto1.CompactTextString(m) } 28 | func (*MultiRowMutationProcessorResponse) ProtoMessage() {} 29 | 30 | type MutateRowsRequest struct { 31 | MutationRequest []*MutationProto `protobuf:"bytes,1,rep,name=mutation_request" json:"mutation_request,omitempty"` 32 | NonceGroup *uint64 `protobuf:"varint,2,opt,name=nonce_group" json:"nonce_group,omitempty"` 33 | Nonce *uint64 `protobuf:"varint,3,opt,name=nonce" json:"nonce,omitempty"` 34 | XXX_unrecognized []byte `json:"-"` 35 | } 36 | 37 | func (m *MutateRowsRequest) Reset() { *m = MutateRowsRequest{} } 38 | func (m *MutateRowsRequest) String() string { return proto1.CompactTextString(m) } 39 | func (*MutateRowsRequest) ProtoMessage() {} 40 | 41 | func (m *MutateRowsRequest) GetMutationRequest() []*MutationProto { 42 | if m != nil { 43 | return m.MutationRequest 44 | } 45 | return nil 46 | } 47 | 48 | func (m *MutateRowsRequest) GetNonceGroup() uint64 { 49 | if m != nil && m.NonceGroup != nil { 50 | return *m.NonceGroup 51 | } 52 | return 0 53 | } 54 | 55 | func (m *MutateRowsRequest) GetNonce() uint64 { 56 | if m != nil && m.Nonce != nil { 57 | return *m.Nonce 58 | } 59 | return 0 60 | } 61 | 62 | type MutateRowsResponse struct { 63 | XXX_unrecognized []byte `json:"-"` 64 | } 65 | 66 | func (m *MutateRowsResponse) Reset() { *m = MutateRowsResponse{} } 67 | func (m *MutateRowsResponse) String() string { return proto1.CompactTextString(m) } 68 | func (*MutateRowsResponse) ProtoMessage() {} 69 | 70 | func init() { 71 | } 72 | -------------------------------------------------------------------------------- /proto/RowProcessor.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: RowProcessor.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type ProcessRequest struct { 15 | RowProcessorClassName *string `protobuf:"bytes,1,req,name=row_processor_class_name" json:"row_processor_class_name,omitempty"` 16 | RowProcessorInitializerMessageName *string `protobuf:"bytes,2,opt,name=row_processor_initializer_message_name" json:"row_processor_initializer_message_name,omitempty"` 17 | RowProcessorInitializerMessage []byte `protobuf:"bytes,3,opt,name=row_processor_initializer_message" json:"row_processor_initializer_message,omitempty"` 18 | NonceGroup *uint64 `protobuf:"varint,4,opt,name=nonce_group" json:"nonce_group,omitempty"` 19 | Nonce *uint64 `protobuf:"varint,5,opt,name=nonce" json:"nonce,omitempty"` 20 | XXX_unrecognized []byte `json:"-"` 21 | } 22 | 23 | func (m *ProcessRequest) Reset() { *m = ProcessRequest{} } 24 | func (m *ProcessRequest) String() string { return proto1.CompactTextString(m) } 25 | func (*ProcessRequest) ProtoMessage() {} 26 | 27 | func (m *ProcessRequest) GetRowProcessorClassName() string { 28 | if m != nil && m.RowProcessorClassName != nil { 29 | return *m.RowProcessorClassName 30 | } 31 | return "" 32 | } 33 | 34 | func (m *ProcessRequest) GetRowProcessorInitializerMessageName() string { 35 | if m != nil && m.RowProcessorInitializerMessageName != nil { 36 | return *m.RowProcessorInitializerMessageName 37 | } 38 | return "" 39 | } 40 | 41 | func (m *ProcessRequest) GetRowProcessorInitializerMessage() []byte { 42 | if m != nil { 43 | return m.RowProcessorInitializerMessage 44 | } 45 | return nil 46 | } 47 | 48 | func (m *ProcessRequest) GetNonceGroup() uint64 { 49 | if m != nil && m.NonceGroup != nil { 50 | return *m.NonceGroup 51 | } 52 | return 0 53 | } 54 | 55 | func (m *ProcessRequest) GetNonce() uint64 { 56 | if m != nil && m.Nonce != nil { 57 | return *m.Nonce 58 | } 59 | return 0 60 | } 61 | 62 | type ProcessResponse struct { 63 | RowProcessorResult []byte `protobuf:"bytes,1,req,name=row_processor_result" json:"row_processor_result,omitempty"` 64 | XXX_unrecognized []byte `json:"-"` 65 | } 66 | 67 | func (m *ProcessResponse) Reset() { *m = ProcessResponse{} } 68 | func (m *ProcessResponse) String() string { return proto1.CompactTextString(m) } 69 | func (*ProcessResponse) ProtoMessage() {} 70 | 71 | func (m *ProcessResponse) GetRowProcessorResult() []byte { 72 | if m != nil { 73 | return m.RowProcessorResult 74 | } 75 | return nil 76 | } 77 | 78 | func init() { 79 | } 80 | -------------------------------------------------------------------------------- /proto/SecureBulkLoad.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: SecureBulkLoad.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type SecureBulkLoadHFilesRequest struct { 15 | FamilyPath []*BulkLoadHFileRequest_FamilyPath `protobuf:"bytes,1,rep,name=family_path" json:"family_path,omitempty"` 16 | AssignSeqNum *bool `protobuf:"varint,2,opt,name=assign_seq_num" json:"assign_seq_num,omitempty"` 17 | FsToken *DelegationToken `protobuf:"bytes,3,req,name=fs_token" json:"fs_token,omitempty"` 18 | BulkToken *string `protobuf:"bytes,4,req,name=bulk_token" json:"bulk_token,omitempty"` 19 | XXX_unrecognized []byte `json:"-"` 20 | } 21 | 22 | func (m *SecureBulkLoadHFilesRequest) Reset() { *m = SecureBulkLoadHFilesRequest{} } 23 | func (m *SecureBulkLoadHFilesRequest) String() string { return proto1.CompactTextString(m) } 24 | func (*SecureBulkLoadHFilesRequest) ProtoMessage() {} 25 | 26 | func (m *SecureBulkLoadHFilesRequest) GetFamilyPath() []*BulkLoadHFileRequest_FamilyPath { 27 | if m != nil { 28 | return m.FamilyPath 29 | } 30 | return nil 31 | } 32 | 33 | func (m *SecureBulkLoadHFilesRequest) GetAssignSeqNum() bool { 34 | if m != nil && m.AssignSeqNum != nil { 35 | return *m.AssignSeqNum 36 | } 37 | return false 38 | } 39 | 40 | func (m *SecureBulkLoadHFilesRequest) GetFsToken() *DelegationToken { 41 | if m != nil { 42 | return m.FsToken 43 | } 44 | return nil 45 | } 46 | 47 | func (m *SecureBulkLoadHFilesRequest) GetBulkToken() string { 48 | if m != nil && m.BulkToken != nil { 49 | return *m.BulkToken 50 | } 51 | return "" 52 | } 53 | 54 | type SecureBulkLoadHFilesResponse struct { 55 | Loaded *bool `protobuf:"varint,1,req,name=loaded" json:"loaded,omitempty"` 56 | XXX_unrecognized []byte `json:"-"` 57 | } 58 | 59 | func (m *SecureBulkLoadHFilesResponse) Reset() { *m = SecureBulkLoadHFilesResponse{} } 60 | func (m *SecureBulkLoadHFilesResponse) String() string { return proto1.CompactTextString(m) } 61 | func (*SecureBulkLoadHFilesResponse) ProtoMessage() {} 62 | 63 | func (m *SecureBulkLoadHFilesResponse) GetLoaded() bool { 64 | if m != nil && m.Loaded != nil { 65 | return *m.Loaded 66 | } 67 | return false 68 | } 69 | 70 | type DelegationToken struct { 71 | Identifier []byte `protobuf:"bytes,1,opt,name=identifier" json:"identifier,omitempty"` 72 | Password []byte `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"` 73 | Kind *string `protobuf:"bytes,3,opt,name=kind" json:"kind,omitempty"` 74 | Service *string `protobuf:"bytes,4,opt,name=service" json:"service,omitempty"` 75 | XXX_unrecognized []byte `json:"-"` 76 | } 77 | 78 | func (m *DelegationToken) Reset() { *m = DelegationToken{} } 79 | func (m *DelegationToken) String() string { return proto1.CompactTextString(m) } 80 | func (*DelegationToken) ProtoMessage() {} 81 | 82 | func (m *DelegationToken) GetIdentifier() []byte { 83 | if m != nil { 84 | return m.Identifier 85 | } 86 | return nil 87 | } 88 | 89 | func (m *DelegationToken) GetPassword() []byte { 90 | if m != nil { 91 | return m.Password 92 | } 93 | return nil 94 | } 95 | 96 | func (m *DelegationToken) GetKind() string { 97 | if m != nil && m.Kind != nil { 98 | return *m.Kind 99 | } 100 | return "" 101 | } 102 | 103 | func (m *DelegationToken) GetService() string { 104 | if m != nil && m.Service != nil { 105 | return *m.Service 106 | } 107 | return "" 108 | } 109 | 110 | type PrepareBulkLoadRequest struct { 111 | TableName *TableName `protobuf:"bytes,1,req,name=table_name" json:"table_name,omitempty"` 112 | XXX_unrecognized []byte `json:"-"` 113 | } 114 | 115 | func (m *PrepareBulkLoadRequest) Reset() { *m = PrepareBulkLoadRequest{} } 116 | func (m *PrepareBulkLoadRequest) String() string { return proto1.CompactTextString(m) } 117 | func (*PrepareBulkLoadRequest) ProtoMessage() {} 118 | 119 | func (m *PrepareBulkLoadRequest) GetTableName() *TableName { 120 | if m != nil { 121 | return m.TableName 122 | } 123 | return nil 124 | } 125 | 126 | type PrepareBulkLoadResponse struct { 127 | BulkToken *string `protobuf:"bytes,1,req,name=bulk_token" json:"bulk_token,omitempty"` 128 | XXX_unrecognized []byte `json:"-"` 129 | } 130 | 131 | func (m *PrepareBulkLoadResponse) Reset() { *m = PrepareBulkLoadResponse{} } 132 | func (m *PrepareBulkLoadResponse) String() string { return proto1.CompactTextString(m) } 133 | func (*PrepareBulkLoadResponse) ProtoMessage() {} 134 | 135 | func (m *PrepareBulkLoadResponse) GetBulkToken() string { 136 | if m != nil && m.BulkToken != nil { 137 | return *m.BulkToken 138 | } 139 | return "" 140 | } 141 | 142 | type CleanupBulkLoadRequest struct { 143 | BulkToken *string `protobuf:"bytes,1,req,name=bulk_token" json:"bulk_token,omitempty"` 144 | XXX_unrecognized []byte `json:"-"` 145 | } 146 | 147 | func (m *CleanupBulkLoadRequest) Reset() { *m = CleanupBulkLoadRequest{} } 148 | func (m *CleanupBulkLoadRequest) String() string { return proto1.CompactTextString(m) } 149 | func (*CleanupBulkLoadRequest) ProtoMessage() {} 150 | 151 | func (m *CleanupBulkLoadRequest) GetBulkToken() string { 152 | if m != nil && m.BulkToken != nil { 153 | return *m.BulkToken 154 | } 155 | return "" 156 | } 157 | 158 | type CleanupBulkLoadResponse struct { 159 | XXX_unrecognized []byte `json:"-"` 160 | } 161 | 162 | func (m *CleanupBulkLoadResponse) Reset() { *m = CleanupBulkLoadResponse{} } 163 | func (m *CleanupBulkLoadResponse) String() string { return proto1.CompactTextString(m) } 164 | func (*CleanupBulkLoadResponse) ProtoMessage() {} 165 | 166 | func init() { 167 | } 168 | -------------------------------------------------------------------------------- /proto/Snapshot.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Snapshot.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type SnapshotFileInfo_Type int32 15 | 16 | const ( 17 | SnapshotFileInfo_HFILE SnapshotFileInfo_Type = 1 18 | SnapshotFileInfo_WAL SnapshotFileInfo_Type = 2 19 | ) 20 | 21 | var SnapshotFileInfo_Type_name = map[int32]string{ 22 | 1: "HFILE", 23 | 2: "WAL", 24 | } 25 | var SnapshotFileInfo_Type_value = map[string]int32{ 26 | "HFILE": 1, 27 | "WAL": 2, 28 | } 29 | 30 | func (x SnapshotFileInfo_Type) Enum() *SnapshotFileInfo_Type { 31 | p := new(SnapshotFileInfo_Type) 32 | *p = x 33 | return p 34 | } 35 | func (x SnapshotFileInfo_Type) String() string { 36 | return proto1.EnumName(SnapshotFileInfo_Type_name, int32(x)) 37 | } 38 | func (x *SnapshotFileInfo_Type) UnmarshalJSON(data []byte) error { 39 | value, err := proto1.UnmarshalJSONEnum(SnapshotFileInfo_Type_value, data, "SnapshotFileInfo_Type") 40 | if err != nil { 41 | return err 42 | } 43 | *x = SnapshotFileInfo_Type(value) 44 | return nil 45 | } 46 | 47 | type SnapshotFileInfo struct { 48 | Type *SnapshotFileInfo_Type `protobuf:"varint,1,req,name=type,enum=proto.SnapshotFileInfo_Type" json:"type,omitempty"` 49 | Hfile *string `protobuf:"bytes,3,opt,name=hfile" json:"hfile,omitempty"` 50 | WalServer *string `protobuf:"bytes,4,opt,name=wal_server" json:"wal_server,omitempty"` 51 | WalName *string `protobuf:"bytes,5,opt,name=wal_name" json:"wal_name,omitempty"` 52 | XXX_unrecognized []byte `json:"-"` 53 | } 54 | 55 | func (m *SnapshotFileInfo) Reset() { *m = SnapshotFileInfo{} } 56 | func (m *SnapshotFileInfo) String() string { return proto1.CompactTextString(m) } 57 | func (*SnapshotFileInfo) ProtoMessage() {} 58 | 59 | func (m *SnapshotFileInfo) GetType() SnapshotFileInfo_Type { 60 | if m != nil && m.Type != nil { 61 | return *m.Type 62 | } 63 | return SnapshotFileInfo_HFILE 64 | } 65 | 66 | func (m *SnapshotFileInfo) GetHfile() string { 67 | if m != nil && m.Hfile != nil { 68 | return *m.Hfile 69 | } 70 | return "" 71 | } 72 | 73 | func (m *SnapshotFileInfo) GetWalServer() string { 74 | if m != nil && m.WalServer != nil { 75 | return *m.WalServer 76 | } 77 | return "" 78 | } 79 | 80 | func (m *SnapshotFileInfo) GetWalName() string { 81 | if m != nil && m.WalName != nil { 82 | return *m.WalName 83 | } 84 | return "" 85 | } 86 | 87 | type SnapshotRegionManifest struct { 88 | Version *int32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` 89 | RegionInfo *RegionInfo `protobuf:"bytes,2,req,name=region_info" json:"region_info,omitempty"` 90 | FamilyFiles []*SnapshotRegionManifest_FamilyFiles `protobuf:"bytes,3,rep,name=family_files" json:"family_files,omitempty"` 91 | XXX_unrecognized []byte `json:"-"` 92 | } 93 | 94 | func (m *SnapshotRegionManifest) Reset() { *m = SnapshotRegionManifest{} } 95 | func (m *SnapshotRegionManifest) String() string { return proto1.CompactTextString(m) } 96 | func (*SnapshotRegionManifest) ProtoMessage() {} 97 | 98 | func (m *SnapshotRegionManifest) GetVersion() int32 { 99 | if m != nil && m.Version != nil { 100 | return *m.Version 101 | } 102 | return 0 103 | } 104 | 105 | func (m *SnapshotRegionManifest) GetRegionInfo() *RegionInfo { 106 | if m != nil { 107 | return m.RegionInfo 108 | } 109 | return nil 110 | } 111 | 112 | func (m *SnapshotRegionManifest) GetFamilyFiles() []*SnapshotRegionManifest_FamilyFiles { 113 | if m != nil { 114 | return m.FamilyFiles 115 | } 116 | return nil 117 | } 118 | 119 | type SnapshotRegionManifest_StoreFile struct { 120 | Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` 121 | Reference *Reference `protobuf:"bytes,2,opt,name=reference" json:"reference,omitempty"` 122 | // TODO: Add checksums or other fields to verify the file 123 | FileSize *uint64 `protobuf:"varint,3,opt,name=file_size" json:"file_size,omitempty"` 124 | XXX_unrecognized []byte `json:"-"` 125 | } 126 | 127 | func (m *SnapshotRegionManifest_StoreFile) Reset() { *m = SnapshotRegionManifest_StoreFile{} } 128 | func (m *SnapshotRegionManifest_StoreFile) String() string { return proto1.CompactTextString(m) } 129 | func (*SnapshotRegionManifest_StoreFile) ProtoMessage() {} 130 | 131 | func (m *SnapshotRegionManifest_StoreFile) GetName() string { 132 | if m != nil && m.Name != nil { 133 | return *m.Name 134 | } 135 | return "" 136 | } 137 | 138 | func (m *SnapshotRegionManifest_StoreFile) GetReference() *Reference { 139 | if m != nil { 140 | return m.Reference 141 | } 142 | return nil 143 | } 144 | 145 | func (m *SnapshotRegionManifest_StoreFile) GetFileSize() uint64 { 146 | if m != nil && m.FileSize != nil { 147 | return *m.FileSize 148 | } 149 | return 0 150 | } 151 | 152 | type SnapshotRegionManifest_FamilyFiles struct { 153 | FamilyName []byte `protobuf:"bytes,1,req,name=family_name" json:"family_name,omitempty"` 154 | StoreFiles []*SnapshotRegionManifest_StoreFile `protobuf:"bytes,2,rep,name=store_files" json:"store_files,omitempty"` 155 | XXX_unrecognized []byte `json:"-"` 156 | } 157 | 158 | func (m *SnapshotRegionManifest_FamilyFiles) Reset() { *m = SnapshotRegionManifest_FamilyFiles{} } 159 | func (m *SnapshotRegionManifest_FamilyFiles) String() string { return proto1.CompactTextString(m) } 160 | func (*SnapshotRegionManifest_FamilyFiles) ProtoMessage() {} 161 | 162 | func (m *SnapshotRegionManifest_FamilyFiles) GetFamilyName() []byte { 163 | if m != nil { 164 | return m.FamilyName 165 | } 166 | return nil 167 | } 168 | 169 | func (m *SnapshotRegionManifest_FamilyFiles) GetStoreFiles() []*SnapshotRegionManifest_StoreFile { 170 | if m != nil { 171 | return m.StoreFiles 172 | } 173 | return nil 174 | } 175 | 176 | type SnapshotDataManifest struct { 177 | TableSchema *TableSchema `protobuf:"bytes,1,req,name=table_schema" json:"table_schema,omitempty"` 178 | RegionManifests []*SnapshotRegionManifest `protobuf:"bytes,2,rep,name=region_manifests" json:"region_manifests,omitempty"` 179 | XXX_unrecognized []byte `json:"-"` 180 | } 181 | 182 | func (m *SnapshotDataManifest) Reset() { *m = SnapshotDataManifest{} } 183 | func (m *SnapshotDataManifest) String() string { return proto1.CompactTextString(m) } 184 | func (*SnapshotDataManifest) ProtoMessage() {} 185 | 186 | func (m *SnapshotDataManifest) GetTableSchema() *TableSchema { 187 | if m != nil { 188 | return m.TableSchema 189 | } 190 | return nil 191 | } 192 | 193 | func (m *SnapshotDataManifest) GetRegionManifests() []*SnapshotRegionManifest { 194 | if m != nil { 195 | return m.RegionManifests 196 | } 197 | return nil 198 | } 199 | 200 | func init() { 201 | proto1.RegisterEnum("proto.SnapshotFileInfo_Type", SnapshotFileInfo_Type_name, SnapshotFileInfo_Type_value) 202 | } 203 | -------------------------------------------------------------------------------- /proto/Tracing.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: Tracing.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | // Used to pass through the information necessary to continue 15 | // a trace after an RPC is made. All we need is the traceid 16 | // (so we know the overarching trace this message is a part of), and 17 | // the id of the current span when this message was sent, so we know 18 | // what span caused the new span we will create when this message is received. 19 | type RPCTInfo struct { 20 | TraceId *int64 `protobuf:"varint,1,opt,name=trace_id" json:"trace_id,omitempty"` 21 | ParentId *int64 `protobuf:"varint,2,opt,name=parent_id" json:"parent_id,omitempty"` 22 | XXX_unrecognized []byte `json:"-"` 23 | } 24 | 25 | func (m *RPCTInfo) Reset() { *m = RPCTInfo{} } 26 | func (m *RPCTInfo) String() string { return proto1.CompactTextString(m) } 27 | func (*RPCTInfo) ProtoMessage() {} 28 | 29 | func (m *RPCTInfo) GetTraceId() int64 { 30 | if m != nil && m.TraceId != nil { 31 | return *m.TraceId 32 | } 33 | return 0 34 | } 35 | 36 | func (m *RPCTInfo) GetParentId() int64 { 37 | if m != nil && m.ParentId != nil { 38 | return *m.ParentId 39 | } 40 | return 0 41 | } 42 | 43 | func init() { 44 | } 45 | -------------------------------------------------------------------------------- /proto/VisibilityLabels.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: VisibilityLabels.proto 3 | // DO NOT EDIT! 4 | 5 | package proto 6 | 7 | import proto1 "github.com/golang/protobuf/proto" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto1.Marshal 12 | var _ = math.Inf 13 | 14 | type VisibilityLabelsRequest struct { 15 | VisLabel []*VisibilityLabel `protobuf:"bytes,1,rep,name=visLabel" json:"visLabel,omitempty"` 16 | XXX_unrecognized []byte `json:"-"` 17 | } 18 | 19 | func (m *VisibilityLabelsRequest) Reset() { *m = VisibilityLabelsRequest{} } 20 | func (m *VisibilityLabelsRequest) String() string { return proto1.CompactTextString(m) } 21 | func (*VisibilityLabelsRequest) ProtoMessage() {} 22 | 23 | func (m *VisibilityLabelsRequest) GetVisLabel() []*VisibilityLabel { 24 | if m != nil { 25 | return m.VisLabel 26 | } 27 | return nil 28 | } 29 | 30 | type VisibilityLabel struct { 31 | Label []byte `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` 32 | Ordinal *uint32 `protobuf:"varint,2,opt,name=ordinal" json:"ordinal,omitempty"` 33 | XXX_unrecognized []byte `json:"-"` 34 | } 35 | 36 | func (m *VisibilityLabel) Reset() { *m = VisibilityLabel{} } 37 | func (m *VisibilityLabel) String() string { return proto1.CompactTextString(m) } 38 | func (*VisibilityLabel) ProtoMessage() {} 39 | 40 | func (m *VisibilityLabel) GetLabel() []byte { 41 | if m != nil { 42 | return m.Label 43 | } 44 | return nil 45 | } 46 | 47 | func (m *VisibilityLabel) GetOrdinal() uint32 { 48 | if m != nil && m.Ordinal != nil { 49 | return *m.Ordinal 50 | } 51 | return 0 52 | } 53 | 54 | type VisibilityLabelsResponse struct { 55 | Result []*RegionActionResult `protobuf:"bytes,1,rep,name=result" json:"result,omitempty"` 56 | XXX_unrecognized []byte `json:"-"` 57 | } 58 | 59 | func (m *VisibilityLabelsResponse) Reset() { *m = VisibilityLabelsResponse{} } 60 | func (m *VisibilityLabelsResponse) String() string { return proto1.CompactTextString(m) } 61 | func (*VisibilityLabelsResponse) ProtoMessage() {} 62 | 63 | func (m *VisibilityLabelsResponse) GetResult() []*RegionActionResult { 64 | if m != nil { 65 | return m.Result 66 | } 67 | return nil 68 | } 69 | 70 | type SetAuthsRequest struct { 71 | User []byte `protobuf:"bytes,1,req,name=user" json:"user,omitempty"` 72 | Auth [][]byte `protobuf:"bytes,2,rep,name=auth" json:"auth,omitempty"` 73 | XXX_unrecognized []byte `json:"-"` 74 | } 75 | 76 | func (m *SetAuthsRequest) Reset() { *m = SetAuthsRequest{} } 77 | func (m *SetAuthsRequest) String() string { return proto1.CompactTextString(m) } 78 | func (*SetAuthsRequest) ProtoMessage() {} 79 | 80 | func (m *SetAuthsRequest) GetUser() []byte { 81 | if m != nil { 82 | return m.User 83 | } 84 | return nil 85 | } 86 | 87 | func (m *SetAuthsRequest) GetAuth() [][]byte { 88 | if m != nil { 89 | return m.Auth 90 | } 91 | return nil 92 | } 93 | 94 | type UserAuthorizations struct { 95 | User []byte `protobuf:"bytes,1,req,name=user" json:"user,omitempty"` 96 | Auth []uint32 `protobuf:"varint,2,rep,name=auth" json:"auth,omitempty"` 97 | XXX_unrecognized []byte `json:"-"` 98 | } 99 | 100 | func (m *UserAuthorizations) Reset() { *m = UserAuthorizations{} } 101 | func (m *UserAuthorizations) String() string { return proto1.CompactTextString(m) } 102 | func (*UserAuthorizations) ProtoMessage() {} 103 | 104 | func (m *UserAuthorizations) GetUser() []byte { 105 | if m != nil { 106 | return m.User 107 | } 108 | return nil 109 | } 110 | 111 | func (m *UserAuthorizations) GetAuth() []uint32 { 112 | if m != nil { 113 | return m.Auth 114 | } 115 | return nil 116 | } 117 | 118 | type MultiUserAuthorizations struct { 119 | UserAuths []*UserAuthorizations `protobuf:"bytes,1,rep,name=userAuths" json:"userAuths,omitempty"` 120 | XXX_unrecognized []byte `json:"-"` 121 | } 122 | 123 | func (m *MultiUserAuthorizations) Reset() { *m = MultiUserAuthorizations{} } 124 | func (m *MultiUserAuthorizations) String() string { return proto1.CompactTextString(m) } 125 | func (*MultiUserAuthorizations) ProtoMessage() {} 126 | 127 | func (m *MultiUserAuthorizations) GetUserAuths() []*UserAuthorizations { 128 | if m != nil { 129 | return m.UserAuths 130 | } 131 | return nil 132 | } 133 | 134 | type GetAuthsRequest struct { 135 | User []byte `protobuf:"bytes,1,req,name=user" json:"user,omitempty"` 136 | XXX_unrecognized []byte `json:"-"` 137 | } 138 | 139 | func (m *GetAuthsRequest) Reset() { *m = GetAuthsRequest{} } 140 | func (m *GetAuthsRequest) String() string { return proto1.CompactTextString(m) } 141 | func (*GetAuthsRequest) ProtoMessage() {} 142 | 143 | func (m *GetAuthsRequest) GetUser() []byte { 144 | if m != nil { 145 | return m.User 146 | } 147 | return nil 148 | } 149 | 150 | type GetAuthsResponse struct { 151 | User []byte `protobuf:"bytes,1,req,name=user" json:"user,omitempty"` 152 | Auth [][]byte `protobuf:"bytes,2,rep,name=auth" json:"auth,omitempty"` 153 | XXX_unrecognized []byte `json:"-"` 154 | } 155 | 156 | func (m *GetAuthsResponse) Reset() { *m = GetAuthsResponse{} } 157 | func (m *GetAuthsResponse) String() string { return proto1.CompactTextString(m) } 158 | func (*GetAuthsResponse) ProtoMessage() {} 159 | 160 | func (m *GetAuthsResponse) GetUser() []byte { 161 | if m != nil { 162 | return m.User 163 | } 164 | return nil 165 | } 166 | 167 | func (m *GetAuthsResponse) GetAuth() [][]byte { 168 | if m != nil { 169 | return m.Auth 170 | } 171 | return nil 172 | } 173 | 174 | type ListLabelsRequest struct { 175 | Regex *string `protobuf:"bytes,1,opt,name=regex" json:"regex,omitempty"` 176 | XXX_unrecognized []byte `json:"-"` 177 | } 178 | 179 | func (m *ListLabelsRequest) Reset() { *m = ListLabelsRequest{} } 180 | func (m *ListLabelsRequest) String() string { return proto1.CompactTextString(m) } 181 | func (*ListLabelsRequest) ProtoMessage() {} 182 | 183 | func (m *ListLabelsRequest) GetRegex() string { 184 | if m != nil && m.Regex != nil { 185 | return *m.Regex 186 | } 187 | return "" 188 | } 189 | 190 | type ListLabelsResponse struct { 191 | Label [][]byte `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"` 192 | XXX_unrecognized []byte `json:"-"` 193 | } 194 | 195 | func (m *ListLabelsResponse) Reset() { *m = ListLabelsResponse{} } 196 | func (m *ListLabelsResponse) String() string { return proto1.CompactTextString(m) } 197 | func (*ListLabelsResponse) ProtoMessage() {} 198 | 199 | func (m *ListLabelsResponse) GetLabel() [][]byte { 200 | if m != nil { 201 | return m.Label 202 | } 203 | return nil 204 | } 205 | 206 | func init() { 207 | } 208 | -------------------------------------------------------------------------------- /protobuf/AccessControl.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 21 | option java_outer_classname = "AccessControlProtos"; 22 | option java_generic_services = true; 23 | option java_generate_equals_and_hash = true; 24 | option optimize_for = SPEED; 25 | 26 | import "HBase.proto"; 27 | 28 | message Permission { 29 | enum Action { 30 | READ = 0; 31 | WRITE = 1; 32 | EXEC = 2; 33 | CREATE = 3; 34 | ADMIN = 4; 35 | } 36 | enum Type { 37 | Global = 1; 38 | Namespace = 2; 39 | Table = 3; 40 | } 41 | required Type type = 1; 42 | optional GlobalPermission global_permission = 2; 43 | optional NamespacePermission namespace_permission = 3; 44 | optional TablePermission table_permission = 4; 45 | } 46 | 47 | message TablePermission { 48 | optional TableName table_name = 1; 49 | optional bytes family = 2; 50 | optional bytes qualifier = 3; 51 | repeated Permission.Action action = 4; 52 | } 53 | 54 | message NamespacePermission { 55 | optional bytes namespace_name = 1; 56 | repeated Permission.Action action = 2; 57 | } 58 | 59 | message GlobalPermission { 60 | repeated Permission.Action action = 1; 61 | } 62 | 63 | message UserPermission { 64 | required bytes user = 1; 65 | required Permission permission = 3; 66 | } 67 | 68 | /** 69 | * Content of the /hbase/acl/ znode. 70 | */ 71 | message UsersAndPermissions { 72 | message UserPermissions { 73 | required bytes user = 1; 74 | repeated Permission permissions = 2; 75 | } 76 | 77 | repeated UserPermissions user_permissions = 1; 78 | } 79 | 80 | message GrantRequest { 81 | required UserPermission user_permission = 1; 82 | } 83 | 84 | message GrantResponse { 85 | } 86 | 87 | message RevokeRequest { 88 | required UserPermission user_permission = 1; 89 | } 90 | 91 | message RevokeResponse { 92 | } 93 | 94 | message GetUserPermissionsRequest { 95 | optional Permission.Type type = 1; 96 | optional TableName table_name = 2; 97 | optional bytes namespace_name = 3; 98 | } 99 | 100 | message GetUserPermissionsResponse { 101 | repeated UserPermission user_permission = 1; 102 | } 103 | 104 | message CheckPermissionsRequest { 105 | repeated Permission permission = 1; 106 | } 107 | 108 | message CheckPermissionsResponse { 109 | } 110 | 111 | service AccessControlService { 112 | rpc Grant(GrantRequest) 113 | returns (GrantResponse); 114 | 115 | rpc Revoke(RevokeRequest) 116 | returns (RevokeResponse); 117 | 118 | rpc GetUserPermissions(GetUserPermissionsRequest) 119 | returns (GetUserPermissionsResponse); 120 | 121 | rpc CheckPermissions(CheckPermissionsRequest) 122 | returns (CheckPermissionsResponse); 123 | } 124 | -------------------------------------------------------------------------------- /protobuf/Admin.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are used for Admin service. 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "AdminProtos"; 24 | option java_generic_services = true; 25 | option java_generate_equals_and_hash = true; 26 | option optimize_for = SPEED; 27 | 28 | import "Client.proto"; 29 | import "HBase.proto"; 30 | import "WAL.proto"; 31 | 32 | message GetRegionInfoRequest { 33 | required RegionSpecifier region = 1; 34 | optional bool compaction_state = 2; 35 | } 36 | 37 | message GetRegionInfoResponse { 38 | required RegionInfo region_info = 1; 39 | optional CompactionState compaction_state = 2; 40 | optional bool isRecovering = 3; 41 | 42 | enum CompactionState { 43 | NONE = 0; 44 | MINOR = 1; 45 | MAJOR = 2; 46 | MAJOR_AND_MINOR = 3; 47 | } 48 | } 49 | 50 | /** 51 | * Get a list of store files for a set of column families in a particular region. 52 | * If no column family is specified, get the store files for all column families. 53 | */ 54 | message GetStoreFileRequest { 55 | required RegionSpecifier region = 1; 56 | repeated bytes family = 2; 57 | } 58 | 59 | message GetStoreFileResponse { 60 | repeated string store_file = 1; 61 | } 62 | 63 | message GetOnlineRegionRequest { 64 | } 65 | 66 | message GetOnlineRegionResponse { 67 | repeated RegionInfo region_info = 1; 68 | } 69 | 70 | message OpenRegionRequest { 71 | repeated RegionOpenInfo open_info = 1; 72 | // the intended server for this RPC. 73 | optional uint64 serverStartCode = 2; 74 | 75 | message RegionOpenInfo { 76 | required RegionInfo region = 1; 77 | optional uint32 version_of_offline_node = 2; 78 | repeated ServerName favored_nodes = 3; 79 | // open region for distributedLogReplay 80 | optional bool openForDistributedLogReplay = 4; 81 | } 82 | } 83 | 84 | message OpenRegionResponse { 85 | repeated RegionOpeningState opening_state = 1; 86 | 87 | enum RegionOpeningState { 88 | OPENED = 0; 89 | ALREADY_OPENED = 1; 90 | FAILED_OPENING = 2; 91 | } 92 | } 93 | 94 | /** 95 | * Closes the specified region and will use or not use ZK during the close 96 | * according to the specified flag. 97 | */ 98 | message CloseRegionRequest { 99 | required RegionSpecifier region = 1; 100 | optional uint32 version_of_closing_node = 2; 101 | optional bool transition_in_ZK = 3 [default = true]; 102 | optional ServerName destination_server = 4; 103 | // the intended server for this RPC. 104 | optional uint64 serverStartCode = 5; 105 | } 106 | 107 | message CloseRegionResponse { 108 | required bool closed = 1; 109 | } 110 | 111 | /** 112 | * Flushes the MemStore of the specified region. 113 | *

114 | * This method is synchronous. 115 | */ 116 | message FlushRegionRequest { 117 | required RegionSpecifier region = 1; 118 | optional uint64 if_older_than_ts = 2; 119 | } 120 | 121 | message FlushRegionResponse { 122 | required uint64 last_flush_time = 1; 123 | optional bool flushed = 2; 124 | } 125 | 126 | /** 127 | * Splits the specified region. 128 | *

129 | * This method currently flushes the region and then forces a compaction which 130 | * will then trigger a split. The flush is done synchronously but the 131 | * compaction is asynchronous. 132 | */ 133 | message SplitRegionRequest { 134 | required RegionSpecifier region = 1; 135 | optional bytes split_point = 2; 136 | } 137 | 138 | message SplitRegionResponse { 139 | } 140 | 141 | /** 142 | * Compacts the specified region. Performs a major compaction if specified. 143 | *

144 | * This method is asynchronous. 145 | */ 146 | message CompactRegionRequest { 147 | required RegionSpecifier region = 1; 148 | optional bool major = 2; 149 | optional bytes family = 3; 150 | } 151 | 152 | message CompactRegionResponse { 153 | } 154 | 155 | message UpdateFavoredNodesRequest { 156 | repeated RegionUpdateInfo update_info = 1; 157 | 158 | message RegionUpdateInfo { 159 | required RegionInfo region = 1; 160 | repeated ServerName favored_nodes = 2; 161 | } 162 | } 163 | 164 | message UpdateFavoredNodesResponse { 165 | optional uint32 response = 1; 166 | } 167 | 168 | /** 169 | * Merges the specified regions. 170 | *

171 | * This method currently closes the regions and then merges them 172 | */ 173 | message MergeRegionsRequest { 174 | required RegionSpecifier region_a = 1; 175 | required RegionSpecifier region_b = 2; 176 | optional bool forcible = 3 [default = false]; 177 | } 178 | 179 | message MergeRegionsResponse { 180 | } 181 | 182 | // Protocol buffer version of WAL for replication 183 | message WALEntry { 184 | required WALKey key = 1; 185 | // Following may be null if the KVs/Cells are carried along the side in a cellblock (See 186 | // RPC for more on cellblocks). If Cells/KVs are in a cellblock, this next field is null 187 | // and associated_cell_count has count of Cells associated w/ this WALEntry 188 | repeated bytes key_value_bytes = 2; 189 | // If Cell data is carried alongside in a cellblock, this is count of Cells in the cellblock. 190 | optional int32 associated_cell_count = 3; 191 | } 192 | 193 | /** 194 | * Replicates the given entries. The guarantee is that the given entries 195 | * will be durable on the slave cluster if this method returns without 196 | * any exception. hbase.replication has to be set to true for this to work. 197 | */ 198 | message ReplicateWALEntryRequest { 199 | repeated WALEntry entry = 1; 200 | } 201 | 202 | message ReplicateWALEntryResponse { 203 | } 204 | 205 | message RollWALWriterRequest { 206 | } 207 | 208 | message RollWALWriterResponse { 209 | // A list of encoded name of regions to flush 210 | repeated bytes region_to_flush = 1; 211 | } 212 | 213 | message StopServerRequest { 214 | required string reason = 1; 215 | } 216 | 217 | message StopServerResponse { 218 | } 219 | 220 | message GetServerInfoRequest { 221 | } 222 | 223 | message ServerInfo { 224 | required ServerName server_name = 1; 225 | optional uint32 webui_port = 2; 226 | } 227 | 228 | message GetServerInfoResponse { 229 | required ServerInfo server_info = 1; 230 | } 231 | 232 | service AdminService { 233 | rpc GetRegionInfo(GetRegionInfoRequest) 234 | returns(GetRegionInfoResponse); 235 | 236 | rpc GetStoreFile(GetStoreFileRequest) 237 | returns(GetStoreFileResponse); 238 | 239 | rpc GetOnlineRegion(GetOnlineRegionRequest) 240 | returns(GetOnlineRegionResponse); 241 | 242 | rpc OpenRegion(OpenRegionRequest) 243 | returns(OpenRegionResponse); 244 | 245 | rpc CloseRegion(CloseRegionRequest) 246 | returns(CloseRegionResponse); 247 | 248 | rpc FlushRegion(FlushRegionRequest) 249 | returns(FlushRegionResponse); 250 | 251 | rpc SplitRegion(SplitRegionRequest) 252 | returns(SplitRegionResponse); 253 | 254 | rpc CompactRegion(CompactRegionRequest) 255 | returns(CompactRegionResponse); 256 | 257 | rpc MergeRegions(MergeRegionsRequest) 258 | returns(MergeRegionsResponse); 259 | 260 | rpc ReplicateWALEntry(ReplicateWALEntryRequest) 261 | returns(ReplicateWALEntryResponse); 262 | 263 | rpc Replay(ReplicateWALEntryRequest) 264 | returns(ReplicateWALEntryResponse); 265 | 266 | rpc RollWALWriter(RollWALWriterRequest) 267 | returns(RollWALWriterResponse); 268 | 269 | rpc GetServerInfo(GetServerInfoRequest) 270 | returns(GetServerInfoResponse); 271 | 272 | rpc StopServer(StopServerRequest) 273 | returns(StopServerResponse); 274 | 275 | rpc UpdateFavoredNodes(UpdateFavoredNodesRequest) 276 | returns(UpdateFavoredNodesResponse); 277 | } 278 | -------------------------------------------------------------------------------- /protobuf/Aggregate.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 21 | option java_outer_classname = "AggregateProtos"; 22 | option java_generic_services = true; 23 | option java_generate_equals_and_hash = true; 24 | option optimize_for = SPEED; 25 | 26 | import "Client.proto"; 27 | 28 | message AggregateRequest { 29 | /** The request passed to the AggregateService consists of three parts 30 | * (1) the (canonical) classname of the ColumnInterpreter implementation 31 | * (2) the Scan query 32 | * (3) any bytes required to construct the ColumnInterpreter object 33 | * properly 34 | */ 35 | required string interpreter_class_name = 1; 36 | required Scan scan = 2; 37 | optional bytes interpreter_specific_bytes = 3; 38 | } 39 | 40 | message AggregateResponse { 41 | /** 42 | * The AggregateService methods all have a response that either is a Pair 43 | * or a simple object. When it is a Pair both first_part and second_part 44 | * have defined values (and the second_part is not present in the response 45 | * when the response is not a pair). Refer to the AggregateImplementation 46 | * class for an overview of the AggregateResponse object constructions. 47 | */ 48 | repeated bytes first_part = 1; 49 | optional bytes second_part = 2; 50 | } 51 | 52 | /** Refer to the AggregateImplementation class for an overview of the 53 | * AggregateService method implementations and their functionality. 54 | */ 55 | service AggregateService { 56 | rpc GetMax (AggregateRequest) returns (AggregateResponse); 57 | rpc GetMin (AggregateRequest) returns (AggregateResponse); 58 | rpc GetSum (AggregateRequest) returns (AggregateResponse); 59 | rpc GetRowNum (AggregateRequest) returns (AggregateResponse); 60 | rpc GetAvg (AggregateRequest) returns (AggregateResponse); 61 | rpc GetStd (AggregateRequest) returns (AggregateResponse); 62 | rpc GetMedian (AggregateRequest) returns (AggregateResponse); 63 | } 64 | -------------------------------------------------------------------------------- /protobuf/Authentication.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 21 | option java_outer_classname = "AuthenticationProtos"; 22 | option java_generic_services = true; 23 | option java_generate_equals_and_hash = true; 24 | option optimize_for = SPEED; 25 | 26 | message AuthenticationKey { 27 | required int32 id = 1; 28 | required int64 expiration_date = 2; 29 | required bytes key = 3; 30 | } 31 | 32 | 33 | message TokenIdentifier { 34 | enum Kind { 35 | HBASE_AUTH_TOKEN = 0; 36 | } 37 | required Kind kind = 1; 38 | required bytes username = 2; 39 | required int32 key_id = 3; 40 | optional int64 issue_date = 4; 41 | optional int64 expiration_date = 5; 42 | optional int64 sequence_number = 6; 43 | } 44 | 45 | 46 | // Serialization of the org.apache.hadoop.security.token.Token class 47 | // Note that this is a Hadoop class, so fields may change! 48 | message Token { 49 | // the TokenIdentifier in serialized form 50 | // Note: we can't use the protobuf directly because the Hadoop Token class 51 | // only stores the serialized bytes 52 | optional bytes identifier = 1; 53 | optional bytes password = 2; 54 | optional bytes service = 3; 55 | } 56 | 57 | 58 | // RPC request & response messages 59 | message GetAuthenticationTokenRequest { 60 | } 61 | 62 | message GetAuthenticationTokenResponse { 63 | optional Token token = 1; 64 | } 65 | 66 | message WhoAmIRequest { 67 | } 68 | 69 | message WhoAmIResponse { 70 | optional string username = 1; 71 | optional string auth_method = 2; 72 | } 73 | 74 | 75 | // RPC service 76 | service AuthenticationService { 77 | rpc GetAuthenticationToken(GetAuthenticationTokenRequest) 78 | returns (GetAuthenticationTokenResponse); 79 | 80 | rpc WhoAmI(WhoAmIRequest) 81 | returns (WhoAmIResponse); 82 | } 83 | -------------------------------------------------------------------------------- /protobuf/Cell.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // Cell and KeyValue protos 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "CellProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | /** 28 | * The type of the key in a Cell 29 | */ 30 | enum CellType { 31 | MINIMUM = 0; 32 | PUT = 4; 33 | 34 | DELETE = 8; 35 | DELETE_COLUMN = 12; 36 | DELETE_FAMILY = 14; 37 | 38 | // MAXIMUM is used when searching; you look from maximum on down. 39 | MAXIMUM = 255; 40 | } 41 | 42 | /** 43 | * Protocol buffer version of Cell. 44 | */ 45 | message Cell { 46 | optional bytes row = 1; 47 | optional bytes family = 2; 48 | optional bytes qualifier = 3; 49 | optional uint64 timestamp = 4; 50 | optional CellType cell_type = 5; 51 | optional bytes value = 6; 52 | optional bytes tags = 7; 53 | } 54 | 55 | /** 56 | * Protocol buffer version of KeyValue. 57 | * It doesn't have those transient parameters 58 | */ 59 | message KeyValue { 60 | required bytes row = 1; 61 | required bytes family = 2; 62 | required bytes qualifier = 3; 63 | optional uint64 timestamp = 4; 64 | optional CellType key_type = 5; 65 | optional bytes value = 6; 66 | optional bytes tags = 7; 67 | } 68 | -------------------------------------------------------------------------------- /protobuf/ClusterId.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are shared throughout HBase 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "ClusterIdProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | /** 28 | * Content of the '/hbase/hbaseid', cluster id, znode. 29 | * Also cluster of the ${HBASE_ROOTDIR}/hbase.id file. 30 | */ 31 | message ClusterId { 32 | // This is the cluster id, a uuid as a String 33 | required string cluster_id = 1; 34 | } 35 | -------------------------------------------------------------------------------- /protobuf/ClusterStatus.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are used for ClustStatus 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "ClusterStatusProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | import "HBase.proto"; 28 | import "ClusterId.proto"; 29 | import "FS.proto"; 30 | 31 | message RegionState { 32 | required RegionInfo region_info = 1; 33 | required State state = 2; 34 | optional uint64 stamp = 3; 35 | enum State { 36 | OFFLINE = 0; // region is in an offline state 37 | PENDING_OPEN = 1; // sent rpc to server to open but has not begun 38 | OPENING = 2; // server has begun to open but not yet done 39 | OPEN = 3; // server opened region and updated meta 40 | PENDING_CLOSE = 4; // sent rpc to server to close but has not begun 41 | CLOSING = 5; // server has begun to close but not yet done 42 | CLOSED = 6; // server closed region and updated meta 43 | SPLITTING = 7; // server started split of a region 44 | SPLIT = 8; // server completed split of a region 45 | FAILED_OPEN = 9; // failed to open, and won't retry any more 46 | FAILED_CLOSE = 10; // failed to close, and won't retry any more 47 | MERGING = 11; // server started merge a region 48 | MERGED = 12; // server completed merge of a region 49 | SPLITTING_NEW = 13; // new region to be created when RS splits a parent 50 | // region but hasn't be created yet, or master doesn't 51 | // know it's already created 52 | MERGING_NEW = 14; // new region to be created when RS merges two 53 | // daughter regions but hasn't be created yet, or 54 | // master doesn't know it's already created 55 | } 56 | } 57 | 58 | message RegionInTransition { 59 | required RegionSpecifier spec = 1; 60 | required RegionState region_state = 2; 61 | } 62 | 63 | message RegionLoad { 64 | /** the region specifier */ 65 | required RegionSpecifier region_specifier = 1; 66 | 67 | /** the number of stores for the region */ 68 | optional uint32 stores = 2; 69 | 70 | /** the number of storefiles for the region */ 71 | optional uint32 storefiles = 3; 72 | 73 | /** the total size of the store files for the region, uncompressed, in MB */ 74 | optional uint32 store_uncompressed_size_MB = 4; 75 | 76 | /** the current total size of the store files for the region, in MB */ 77 | optional uint32 storefile_size_MB = 5; 78 | 79 | /** the current size of the memstore for the region, in MB */ 80 | optional uint32 memstore_size_MB = 6; 81 | 82 | /** 83 | * The current total size of root-level store file indexes for the region, 84 | * in MB. The same as {@link #rootIndexSizeKB} but in MB. 85 | */ 86 | optional uint32 storefile_index_size_MB = 7; 87 | 88 | /** the current total read requests made to region */ 89 | optional uint64 read_requests_count = 8; 90 | 91 | /** the current total write requests made to region */ 92 | optional uint64 write_requests_count = 9; 93 | 94 | /** the total compacting key values in currently running compaction */ 95 | optional uint64 total_compacting_KVs = 10; 96 | 97 | /** the completed count of key values in currently running compaction */ 98 | optional uint64 current_compacted_KVs = 11; 99 | 100 | /** The current total size of root-level indexes for the region, in KB. */ 101 | optional uint32 root_index_size_KB = 12; 102 | 103 | /** The total size of all index blocks, not just the root level, in KB. */ 104 | optional uint32 total_static_index_size_KB = 13; 105 | 106 | /** 107 | * The total size of all Bloom filter blocks, not just loaded into the 108 | * block cache, in KB. 109 | */ 110 | optional uint32 total_static_bloom_size_KB = 14; 111 | 112 | /** the most recent sequence Id from cache flush */ 113 | optional uint64 complete_sequence_id = 15; 114 | 115 | /** The current data locality for region in the regionserver */ 116 | optional float data_locality = 16; 117 | } 118 | 119 | /* Server-level protobufs */ 120 | 121 | message ReplicationLoadSink { 122 | required uint64 ageOfLastAppliedOp = 1; 123 | required uint64 timeStampsOfLastAppliedOp = 2; 124 | } 125 | 126 | message ReplicationLoadSource { 127 | required string peerID = 1; 128 | required uint64 ageOfLastShippedOp = 2; 129 | required uint32 sizeOfLogQueue = 3; 130 | required uint64 timeStampOfLastShippedOp = 4; 131 | required uint64 replicationLag = 5; 132 | } 133 | 134 | message ServerLoad { 135 | /** Number of requests since last report. */ 136 | optional uint32 number_of_requests = 1; 137 | 138 | /** Total Number of requests from the start of the region server. */ 139 | optional uint32 total_number_of_requests = 2; 140 | 141 | /** the amount of used heap, in MB. */ 142 | optional uint32 used_heap_MB = 3; 143 | 144 | /** the maximum allowable size of the heap, in MB. */ 145 | optional uint32 max_heap_MB = 4; 146 | 147 | /** Information on the load of individual regions. */ 148 | repeated RegionLoad region_loads = 5; 149 | 150 | /** 151 | * Regionserver-level coprocessors, e.g., WALObserver implementations. 152 | * Region-level coprocessors, on the other hand, are stored inside RegionLoad 153 | * objects. 154 | */ 155 | repeated Coprocessor coprocessors = 6; 156 | 157 | /** 158 | * Time when incremental (non-total) counts began being calculated (e.g. number_of_requests) 159 | * time is measured as the difference, measured in milliseconds, between the current time 160 | * and midnight, January 1, 1970 UTC. 161 | */ 162 | optional uint64 report_start_time = 7; 163 | 164 | /** 165 | * Time when report was generated. 166 | * time is measured as the difference, measured in milliseconds, between the current time 167 | * and midnight, January 1, 1970 UTC. 168 | */ 169 | optional uint64 report_end_time = 8; 170 | 171 | /** 172 | * The port number that this region server is hosing an info server on. 173 | */ 174 | optional uint32 info_server_port = 9; 175 | 176 | /** 177 | * The replicationLoadSource for the replication Source status of this region server. 178 | */ 179 | repeated ReplicationLoadSource replLoadSource = 10; 180 | 181 | /** 182 | * The replicationLoadSink for the replication Sink status of this region server. 183 | */ 184 | optional ReplicationLoadSink replLoadSink = 11; 185 | } 186 | 187 | message LiveServerInfo { 188 | required ServerName server = 1; 189 | required ServerLoad server_load = 2; 190 | } 191 | 192 | message ClusterStatus { 193 | optional HBaseVersionFileContent hbase_version = 1; 194 | repeated LiveServerInfo live_servers = 2; 195 | repeated ServerName dead_servers = 3; 196 | repeated RegionInTransition regions_in_transition = 4; 197 | optional ClusterId cluster_id = 5; 198 | repeated Coprocessor master_coprocessors = 6; 199 | optional ServerName master = 7; 200 | repeated ServerName backup_masters = 8; 201 | optional bool balancer_on = 9; 202 | } 203 | -------------------------------------------------------------------------------- /protobuf/Comparator.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are used for filters 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "ComparatorProtos"; 24 | option java_generic_services = true; 25 | option java_generate_equals_and_hash = true; 26 | option optimize_for = SPEED; 27 | 28 | // This file contains protocol buffers that are used for comparators (e.g. in filters) 29 | 30 | message Comparator { 31 | required string name = 1; 32 | optional bytes serialized_comparator = 2; 33 | } 34 | 35 | message ByteArrayComparable { 36 | optional bytes value = 1; 37 | } 38 | 39 | message BinaryComparator { 40 | required ByteArrayComparable comparable = 1; 41 | } 42 | 43 | message LongComparator { 44 | required ByteArrayComparable comparable = 1; 45 | } 46 | 47 | message BinaryPrefixComparator { 48 | required ByteArrayComparable comparable = 1; 49 | } 50 | 51 | message BitComparator { 52 | required ByteArrayComparable comparable = 1; 53 | required BitwiseOp bitwise_op = 2; 54 | 55 | enum BitwiseOp { 56 | AND = 1; 57 | OR = 2; 58 | XOR = 3; 59 | } 60 | } 61 | 62 | message NullComparator { 63 | } 64 | 65 | message RegexStringComparator { 66 | required string pattern = 1; 67 | required int32 pattern_flags = 2; 68 | required string charset = 3; 69 | optional string engine = 4; 70 | } 71 | 72 | message SubstringComparator { 73 | required string substr = 1; 74 | } 75 | -------------------------------------------------------------------------------- /protobuf/Encryption.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers used for encryption 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "EncryptionProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | message WrappedKey { 28 | required string algorithm = 1; 29 | required uint32 length = 2; 30 | required bytes data = 3; 31 | optional bytes iv = 4; 32 | optional bytes hash = 5; 33 | } 34 | -------------------------------------------------------------------------------- /protobuf/ErrorHandling.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are used for error handling 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "ErrorHandlingProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | /** 28 | * Protobuf version of a java.lang.StackTraceElement 29 | * so we can serialize exceptions. 30 | */ 31 | message StackTraceElementMessage { 32 | optional string declaring_class = 1; 33 | optional string method_name = 2; 34 | optional string file_name = 3; 35 | optional int32 line_number = 4; 36 | } 37 | 38 | /** 39 | * Cause of a remote failure for a generic exception. Contains 40 | * all the information for a generic exception as well as 41 | * optional info about the error for generic info passing 42 | * (which should be another protobuffed class). 43 | */ 44 | message GenericExceptionMessage { 45 | optional string class_name = 1; 46 | optional string message = 2; 47 | optional bytes error_info = 3; 48 | repeated StackTraceElementMessage trace = 4; 49 | } 50 | 51 | /** 52 | * Exception sent across the wire when a remote task needs 53 | * to notify other tasks that it failed and why 54 | */ 55 | message ForeignExceptionMessage { 56 | optional string source = 1; 57 | optional GenericExceptionMessage generic_exception = 2; 58 | } 59 | -------------------------------------------------------------------------------- /protobuf/FS.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are written into the filesystem 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "FSProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | /** 28 | * The ${HBASE_ROOTDIR}/hbase.version file content 29 | */ 30 | message HBaseVersionFileContent { 31 | required string version = 1; 32 | } 33 | 34 | /** 35 | * Reference file content used when we split an hfile under a region. 36 | */ 37 | message Reference { 38 | required bytes splitkey = 1; 39 | enum Range { 40 | TOP = 0; 41 | BOTTOM = 1; 42 | } 43 | required Range range = 2; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /protobuf/Filter.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are used for filters 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "FilterProtos"; 24 | option java_generic_services = true; 25 | option java_generate_equals_and_hash = true; 26 | option optimize_for = SPEED; 27 | 28 | import "HBase.proto"; 29 | import "Comparator.proto"; 30 | 31 | message Filter { 32 | required string name = 1; 33 | optional bytes serialized_filter = 2; 34 | } 35 | 36 | message ColumnCountGetFilter { 37 | required int32 limit = 1; 38 | } 39 | 40 | message ColumnPaginationFilter { 41 | required int32 limit = 1; 42 | optional int32 offset = 2; 43 | optional bytes column_offset = 3; 44 | } 45 | 46 | message ColumnPrefixFilter { 47 | required bytes prefix = 1; 48 | } 49 | 50 | message ColumnRangeFilter { 51 | optional bytes min_column = 1; 52 | optional bool min_column_inclusive = 2; 53 | optional bytes max_column = 3; 54 | optional bool max_column_inclusive = 4; 55 | } 56 | 57 | message CompareFilter { 58 | required CompareType compare_op = 1; 59 | optional Comparator comparator = 2; 60 | } 61 | 62 | message DependentColumnFilter { 63 | required CompareFilter compare_filter = 1; 64 | optional bytes column_family = 2; 65 | optional bytes column_qualifier = 3; 66 | optional bool drop_dependent_column = 4; 67 | } 68 | 69 | message FamilyFilter { 70 | required CompareFilter compare_filter = 1; 71 | } 72 | 73 | message FilterList { 74 | required Operator operator = 1; 75 | repeated Filter filters = 2; 76 | 77 | enum Operator { 78 | MUST_PASS_ALL = 1; 79 | MUST_PASS_ONE = 2; 80 | } 81 | } 82 | 83 | message FilterWrapper { 84 | required Filter filter = 1; 85 | } 86 | 87 | message FirstKeyOnlyFilter { 88 | } 89 | 90 | message FirstKeyValueMatchingQualifiersFilter { 91 | repeated bytes qualifiers = 1; 92 | } 93 | 94 | message FuzzyRowFilter { 95 | repeated BytesBytesPair fuzzy_keys_data = 1; 96 | } 97 | 98 | message InclusiveStopFilter { 99 | optional bytes stop_row_key = 1; 100 | } 101 | 102 | message KeyOnlyFilter { 103 | required bool len_as_val = 1; 104 | } 105 | 106 | message MultipleColumnPrefixFilter { 107 | repeated bytes sorted_prefixes = 1; 108 | } 109 | 110 | message PageFilter { 111 | required int64 page_size = 1; 112 | } 113 | 114 | message PrefixFilter { 115 | optional bytes prefix = 1; 116 | } 117 | 118 | message QualifierFilter { 119 | required CompareFilter compare_filter = 1; 120 | } 121 | 122 | message RandomRowFilter { 123 | required float chance = 1; 124 | } 125 | 126 | message RowFilter { 127 | required CompareFilter compare_filter = 1; 128 | } 129 | 130 | message SingleColumnValueExcludeFilter { 131 | required SingleColumnValueFilter single_column_value_filter = 1; 132 | } 133 | 134 | message SingleColumnValueFilter { 135 | optional bytes column_family = 1; 136 | optional bytes column_qualifier = 2; 137 | required CompareType compare_op = 3; 138 | required Comparator comparator = 4; 139 | optional bool filter_if_missing = 5; 140 | optional bool latest_version_only = 6; 141 | } 142 | 143 | message SkipFilter { 144 | required Filter filter = 1; 145 | } 146 | 147 | message TimestampsFilter { 148 | repeated int64 timestamps = 1 [packed=true]; 149 | } 150 | 151 | message ValueFilter { 152 | required CompareFilter compare_filter = 1; 153 | } 154 | 155 | message WhileMatchFilter { 156 | required Filter filter = 1; 157 | } 158 | message FilterAllFilter { 159 | } -------------------------------------------------------------------------------- /protobuf/HBase.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are shared throughout HBase 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "HBaseProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | import "Cell.proto"; 28 | 29 | /** 30 | * Table Name 31 | */ 32 | message TableName { 33 | required bytes namespace = 1; 34 | required bytes qualifier = 2; 35 | } 36 | 37 | /** 38 | * Table Schema 39 | * Inspired by the rest TableSchema 40 | */ 41 | message TableSchema { 42 | optional TableName table_name = 1; 43 | repeated BytesBytesPair attributes = 2; 44 | repeated ColumnFamilySchema column_families = 3; 45 | repeated NameStringPair configuration = 4; 46 | } 47 | 48 | /** 49 | * Column Family Schema 50 | * Inspired by the rest ColumSchemaMessage 51 | */ 52 | message ColumnFamilySchema { 53 | required bytes name = 1; 54 | repeated BytesBytesPair attributes = 2; 55 | repeated NameStringPair configuration = 3; 56 | } 57 | 58 | /** 59 | * Protocol buffer version of HRegionInfo. 60 | */ 61 | message RegionInfo { 62 | required uint64 region_id = 1; 63 | required TableName table_name = 2; 64 | optional bytes start_key = 3; 65 | optional bytes end_key = 4; 66 | optional bool offline = 5; 67 | optional bool split = 6; 68 | } 69 | 70 | /** 71 | * Protocol buffer for favored nodes 72 | */ 73 | message FavoredNodes { 74 | repeated ServerName favored_node = 1; 75 | } 76 | 77 | /** 78 | * Container protocol buffer to specify a region. 79 | * You can specify region by region name, or the hash 80 | * of the region name, which is known as encoded 81 | * region name. 82 | */ 83 | message RegionSpecifier { 84 | required RegionSpecifierType type = 1; 85 | required bytes value = 2; 86 | 87 | enum RegionSpecifierType { 88 | // ,,. 89 | REGION_NAME = 1; 90 | 91 | // hash of ,, 92 | ENCODED_REGION_NAME = 2; 93 | } 94 | } 95 | 96 | /** 97 | * A range of time. Both from and to are Java time 98 | * stamp in milliseconds. If you don't specify a time 99 | * range, it means all time. By default, if not 100 | * specified, from = 0, and to = Long.MAX_VALUE 101 | */ 102 | message TimeRange { 103 | optional uint64 from = 1; 104 | optional uint64 to = 2; 105 | } 106 | 107 | /* Comparison operators */ 108 | enum CompareType { 109 | LESS = 0; 110 | LESS_OR_EQUAL = 1; 111 | EQUAL = 2; 112 | NOT_EQUAL = 3; 113 | GREATER_OR_EQUAL = 4; 114 | GREATER = 5; 115 | NO_OP = 6; 116 | } 117 | 118 | /** 119 | * Protocol buffer version of ServerName 120 | */ 121 | message ServerName { 122 | required string host_name = 1; 123 | optional uint32 port = 2; 124 | optional uint64 start_code = 3; 125 | } 126 | 127 | // Comment data structures 128 | 129 | message Coprocessor { 130 | required string name = 1; 131 | } 132 | 133 | message NameStringPair { 134 | required string name = 1; 135 | required string value = 2; 136 | } 137 | 138 | message NameBytesPair { 139 | required string name = 1; 140 | optional bytes value = 2; 141 | } 142 | 143 | message BytesBytesPair { 144 | required bytes first = 1; 145 | required bytes second = 2; 146 | } 147 | 148 | message NameInt64Pair { 149 | optional string name = 1; 150 | optional int64 value = 2; 151 | } 152 | 153 | /** 154 | * Description of the snapshot to take 155 | */ 156 | message SnapshotDescription { 157 | required string name = 1; 158 | optional string table = 2; // not needed for delete, but checked for in taking snapshot 159 | optional int64 creation_time = 3 [default = 0]; 160 | enum Type { 161 | DISABLED = 0; 162 | FLUSH = 1; 163 | SKIPFLUSH = 2; 164 | } 165 | optional Type type = 4 [default = FLUSH]; 166 | optional int32 version = 5; 167 | } 168 | 169 | /** 170 | * Description of the distributed procedure to take 171 | */ 172 | message ProcedureDescription { 173 | required string signature = 1; // the unique signature of the procedure 174 | optional string instance = 2; // the procedure instance name 175 | optional int64 creation_time = 3 [default = 0]; 176 | repeated NameStringPair configuration = 4; 177 | } 178 | 179 | message EmptyMsg { 180 | } 181 | 182 | message LongMsg { 183 | required int64 long_msg = 1; 184 | } 185 | 186 | message DoubleMsg { 187 | required double double_msg = 1; 188 | } 189 | 190 | message BigDecimalMsg { 191 | required bytes bigdecimal_msg = 1; 192 | } 193 | 194 | message UUID { 195 | required uint64 least_sig_bits = 1; 196 | required uint64 most_sig_bits = 2; 197 | } 198 | 199 | message NamespaceDescriptor { 200 | required bytes name = 1; 201 | repeated NameStringPair configuration = 2; 202 | } 203 | 204 | /** 205 | * Description of the region server info 206 | */ 207 | message RegionServerInfo { 208 | optional int32 infoPort = 1; 209 | } 210 | -------------------------------------------------------------------------------- /protobuf/HFile.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 20 | option java_outer_classname = "HFileProtos"; 21 | option java_generic_services = true; 22 | option java_generate_equals_and_hash = true; 23 | option optimize_for = SPEED; 24 | 25 | import "HBase.proto"; 26 | 27 | // Map of name/values 28 | message FileInfoProto { 29 | repeated BytesBytesPair map_entry = 1; 30 | } 31 | 32 | // HFile file trailer 33 | message FileTrailerProto { 34 | optional uint64 file_info_offset = 1; 35 | optional uint64 load_on_open_data_offset = 2; 36 | optional uint64 uncompressed_data_index_size = 3; 37 | optional uint64 total_uncompressed_bytes = 4; 38 | optional uint32 data_index_count = 5; 39 | optional uint32 meta_index_count = 6; 40 | optional uint64 entry_count = 7; 41 | optional uint32 num_data_index_levels = 8; 42 | optional uint64 first_data_block_offset = 9; 43 | optional uint64 last_data_block_offset = 10; 44 | optional string comparator_class_name = 11; 45 | optional uint32 compression_codec = 12; 46 | optional bytes encryption_key = 13; 47 | } 48 | -------------------------------------------------------------------------------- /protobuf/LoadBalancer.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers to represent the state of the load balancer. 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "LoadBalancerProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | message LoadBalancerState { 28 | optional bool balancer_on = 1; 29 | } 30 | -------------------------------------------------------------------------------- /protobuf/MapReduce.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | //This file includes protocol buffers used in MapReduce only. 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "MapReduceProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | import "HBase.proto"; 28 | 29 | message ScanMetrics { 30 | repeated NameInt64Pair metrics = 1; 31 | } 32 | 33 | message TableSnapshotRegionSplit { 34 | repeated string locations = 2; 35 | optional TableSchema table = 3; 36 | optional RegionInfo region = 4; 37 | } 38 | -------------------------------------------------------------------------------- /protobuf/MultiRowMutation.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | import "Client.proto"; 20 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 21 | option java_outer_classname = "MultiRowMutationProtos"; 22 | option java_generate_equals_and_hash = true; 23 | option java_generic_services = true; 24 | option optimize_for = SPEED; 25 | 26 | message MultiRowMutationProcessorRequest{ 27 | } 28 | 29 | message MultiRowMutationProcessorResponse{ 30 | } 31 | 32 | message MutateRowsRequest { 33 | repeated MutationProto mutation_request = 1; 34 | optional uint64 nonce_group = 2; 35 | optional uint64 nonce = 3; 36 | } 37 | 38 | message MutateRowsResponse { 39 | } 40 | 41 | service MultiRowMutationService { 42 | rpc MutateRows(MutateRowsRequest) 43 | returns(MutateRowsResponse); 44 | } -------------------------------------------------------------------------------- /protobuf/RPC.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | import "Tracing.proto"; 20 | import "HBase.proto"; 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "RPCProtos"; 24 | option java_generate_equals_and_hash = true; 25 | option optimize_for = SPEED; 26 | 27 | // See https://issues.apache.org/jira/browse/HBASE-7898 for high-level 28 | // description of RPC specification. 29 | // 30 | // On connection setup, the client sends six bytes of preamble -- a four 31 | // byte magic, a byte of version, and a byte of authentication type. 32 | // 33 | // We then send a "ConnectionHeader" protobuf of user information and the 34 | // 'protocol' or 'service' that is to be run over this connection as well as 35 | // info such as codecs and compression to use when we send cell blocks(see below). 36 | // This connection header protobuf is prefaced by an int that holds the length 37 | // of this connection header (this is NOT a varint). The pb connection header 38 | // is sent with Message#writeTo. The server throws an exception if it doesn't 39 | // like what it was sent noting what it is objecting too. Otherwise, the server 40 | // says nothing and is open for business. 41 | // 42 | // Hereafter the client makes requests and the server returns responses. 43 | // 44 | // Requests look like this: 45 | // 46 | // 47 | // 48 | // 49 | // 50 | // 51 | // ...where the Request Parameter Message is whatever the method name stipulated 52 | // in the RequestHeader expects; e.g. if the method is a scan, then the pb 53 | // Request Message is a GetRequest, or a ScanRequest. A block of Cells 54 | // optionally follows. The presence of a Request param Message and/or a 55 | // block of Cells will be noted in the RequestHeader. 56 | // 57 | // Response is the mirror of the request: 58 | // 59 | // 60 | // 61 | // 62 | // 63 | // 64 | // ...where the Response Message is the response type that goes with the 65 | // method specified when making the request and the follow on Cell blocks may 66 | // or may not be there -- read the response header to find out if one following. 67 | // If an exception, it will be included inside the Response Header. 68 | // 69 | // Any time we write a pb, we do it with Message#writeDelimitedTo EXCEPT when 70 | // the connection header is sent; this is prefaced by an int with its length 71 | // and the pb connection header is then written with Message#writeTo. 72 | // 73 | 74 | // User Information proto. Included in ConnectionHeader on connection setup 75 | message UserInformation { 76 | required string effective_user = 1; 77 | optional string real_user = 2; 78 | } 79 | 80 | // Rpc client version info proto. Included in ConnectionHeader on connection setup 81 | message VersionInfo { 82 | required string version = 1; 83 | required string url = 2; 84 | required string revision = 3; 85 | required string user = 4; 86 | required string date = 5; 87 | required string src_checksum = 6; 88 | } 89 | 90 | // This is sent on connection setup after the connection preamble is sent. 91 | message ConnectionHeader { 92 | optional UserInformation user_info = 1; 93 | optional string service_name = 2; 94 | // Cell block codec we will use sending over optional cell blocks. Server throws exception 95 | // if cannot deal. Null means no codec'ing going on so we are pb all the time (SLOW!!!) 96 | optional string cell_block_codec_class = 3; 97 | // Compressor we will use if cell block is compressed. Server will throw exception if not supported. 98 | // Class must implement hadoop's CompressionCodec Interface. Can't compress if no codec. 99 | optional string cell_block_compressor_class = 4; 100 | optional VersionInfo version_info = 5; 101 | } 102 | 103 | // Optional Cell block Message. Included in client RequestHeader 104 | message CellBlockMeta { 105 | // Length of the following cell block. Could calculate it but convenient having it too hand. 106 | optional uint32 length = 1; 107 | } 108 | 109 | // At the RPC layer, this message is used to carry 110 | // the server side exception to the RPC client. 111 | message ExceptionResponse { 112 | // Class name of the exception thrown from the server 113 | optional string exception_class_name = 1; 114 | // Exception stack trace from the server side 115 | optional string stack_trace = 2; 116 | // Optional hostname. Filled in for some exceptions such as region moved 117 | // where exception gives clue on where the region may have moved. 118 | optional string hostname = 3; 119 | optional int32 port = 4; 120 | // Set if we are NOT to retry on receipt of this exception 121 | optional bool do_not_retry = 5; 122 | } 123 | 124 | // Header sent making a request. 125 | message RequestHeader { 126 | // Monotonically increasing call_id to keep track of RPC requests and their response 127 | optional uint32 call_id = 1; 128 | optional RPCTInfo trace_info = 2; 129 | optional string method_name = 3; 130 | // If true, then a pb Message param follows. 131 | optional bool request_param = 4; 132 | // If present, then an encoded data block follows. 133 | optional CellBlockMeta cell_block_meta = 5; 134 | // 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL. 135 | // See HConstants. 136 | optional uint32 priority = 6; 137 | } 138 | 139 | message ResponseHeader { 140 | optional uint32 call_id = 1; 141 | // If present, then request threw an exception and no response message (else we presume one) 142 | optional ExceptionResponse exception = 2; 143 | // If present, then an encoded data block follows. 144 | optional CellBlockMeta cell_block_meta = 3; 145 | } 146 | -------------------------------------------------------------------------------- /protobuf/RegionServerStatus.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // This file contains protocol buffers that are used for RegionServerStatusProtocol. 21 | 22 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 23 | option java_outer_classname = "RegionServerStatusProtos"; 24 | option java_generic_services = true; 25 | option java_generate_equals_and_hash = true; 26 | option optimize_for = SPEED; 27 | 28 | import "HBase.proto"; 29 | import "ClusterStatus.proto"; 30 | 31 | message RegionServerStartupRequest { 32 | /** Port number this regionserver is up on */ 33 | required uint32 port = 1; 34 | 35 | /** This servers' startcode */ 36 | required uint64 server_start_code = 2; 37 | 38 | /** Current time of the region server in ms */ 39 | required uint64 server_current_time = 3; 40 | } 41 | 42 | message RegionServerStartupResponse { 43 | /** 44 | * Configuration for the regionserver to use: e.g. filesystem, 45 | * hbase rootdir, the hostname to use creating the RegionServer ServerName, 46 | * etc 47 | */ 48 | repeated NameStringPair map_entries = 1; 49 | } 50 | 51 | message RegionServerReportRequest { 52 | required ServerName server = 1; 53 | 54 | /** load the server is under */ 55 | optional ServerLoad load = 2; 56 | } 57 | 58 | message RegionServerReportResponse { 59 | } 60 | 61 | message ReportRSFatalErrorRequest { 62 | /** name of the server experiencing the error */ 63 | required ServerName server = 1; 64 | 65 | /** informative text to expose in the master logs and UI */ 66 | required string error_message = 2; 67 | } 68 | 69 | message ReportRSFatalErrorResponse { 70 | } 71 | 72 | message GetLastFlushedSequenceIdRequest { 73 | /** region name */ 74 | required bytes region_name = 1; 75 | } 76 | 77 | message GetLastFlushedSequenceIdResponse { 78 | /** the last HLog sequence id flushed from MemStore to HFile for the region */ 79 | required uint64 last_flushed_sequence_id = 1; 80 | } 81 | 82 | message RegionStateTransition { 83 | required TransitionCode transition_code = 1; 84 | 85 | /** Mutliple regions are involved during merging/splitting */ 86 | repeated RegionInfo region_info = 2; 87 | 88 | /** For newly opened region, the open seq num is needed */ 89 | optional uint64 open_seq_num = 3; 90 | 91 | enum TransitionCode { 92 | OPENED = 0; 93 | FAILED_OPEN = 1; 94 | /** No failed_close, in which case region server will abort */ 95 | CLOSED = 2; 96 | 97 | /** Ask master for ok to split/merge region(s) */ 98 | READY_TO_SPLIT = 3; 99 | READY_TO_MERGE = 4; 100 | 101 | SPLIT_PONR = 5; 102 | MERGE_PONR = 6; 103 | 104 | SPLIT = 7; 105 | MERGED = 8; 106 | SPLIT_REVERTED = 9; 107 | MERGE_REVERTED = 10; 108 | } 109 | } 110 | 111 | message ReportRegionStateTransitionRequest { 112 | /** This region server's server name */ 113 | required ServerName server = 1; 114 | 115 | repeated RegionStateTransition transition = 2; 116 | } 117 | 118 | message ReportRegionStateTransitionResponse { 119 | /** Error message if failed to update the region state */ 120 | optional string error_message = 1; 121 | } 122 | 123 | service RegionServerStatusService { 124 | /** Called when a region server first starts. */ 125 | rpc RegionServerStartup(RegionServerStartupRequest) 126 | returns(RegionServerStartupResponse); 127 | 128 | /** Called to report the load the RegionServer is under. */ 129 | rpc RegionServerReport(RegionServerReportRequest) 130 | returns(RegionServerReportResponse); 131 | 132 | /** 133 | * Called by a region server to report a fatal error that is causing it to 134 | * abort. 135 | */ 136 | rpc ReportRSFatalError(ReportRSFatalErrorRequest) 137 | returns(ReportRSFatalErrorResponse); 138 | 139 | /** Called to get the sequence id of the last MemStore entry flushed to an 140 | * HFile for a specified region. Used by the region server to speed up 141 | * log splitting. */ 142 | rpc GetLastFlushedSequenceId(GetLastFlushedSequenceIdRequest) 143 | returns(GetLastFlushedSequenceIdResponse); 144 | 145 | /** 146 | * Called by a region server to report the progress of a region 147 | * transition. If the request fails, the transition should 148 | * be aborted. 149 | */ 150 | rpc ReportRegionStateTransition(ReportRegionStateTransitionRequest) 151 | returns(ReportRegionStateTransitionResponse); 152 | } 153 | -------------------------------------------------------------------------------- /protobuf/RowProcessor.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | /** 20 | * Defines a protocol to perform multi row transactions. 21 | * See BaseRowProcessorEndpoint for the implementation. 22 | * See HRegion#processRowsWithLocks() for details. 23 | */ 24 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 25 | option java_outer_classname = "RowProcessorProtos"; 26 | option java_generic_services = true; 27 | option java_generate_equals_and_hash = true; 28 | option optimize_for = SPEED; 29 | 30 | message ProcessRequest { 31 | required string row_processor_class_name = 1; 32 | optional string row_processor_initializer_message_name = 2; 33 | optional bytes row_processor_initializer_message = 3; 34 | optional uint64 nonce_group = 4; 35 | optional uint64 nonce = 5; 36 | } 37 | 38 | message ProcessResponse { 39 | required bytes row_processor_result = 1; 40 | } 41 | 42 | service RowProcessorService { 43 | rpc Process(ProcessRequest) returns (ProcessResponse); 44 | } 45 | -------------------------------------------------------------------------------- /protobuf/SecureBulkLoad.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 21 | option java_outer_classname = "SecureBulkLoadProtos"; 22 | option java_generic_services = true; 23 | option java_generate_equals_and_hash = true; 24 | option optimize_for = SPEED; 25 | 26 | import 'HBase.proto'; 27 | import 'Client.proto'; 28 | 29 | message SecureBulkLoadHFilesRequest { 30 | repeated BulkLoadHFileRequest.FamilyPath family_path = 1; 31 | optional bool assign_seq_num = 2; 32 | required DelegationToken fs_token = 3; 33 | required string bulk_token = 4; 34 | } 35 | 36 | message SecureBulkLoadHFilesResponse { 37 | required bool loaded = 1; 38 | } 39 | 40 | message DelegationToken { 41 | optional bytes identifier = 1; 42 | optional bytes password = 2; 43 | optional string kind = 3; 44 | optional string service = 4; 45 | } 46 | 47 | message PrepareBulkLoadRequest { 48 | required TableName table_name = 1; 49 | } 50 | 51 | message PrepareBulkLoadResponse { 52 | required string bulk_token = 1; 53 | } 54 | 55 | message CleanupBulkLoadRequest { 56 | required string bulk_token = 1; 57 | 58 | } 59 | 60 | message CleanupBulkLoadResponse { 61 | } 62 | 63 | service SecureBulkLoadService { 64 | rpc PrepareBulkLoad(PrepareBulkLoadRequest) 65 | returns (PrepareBulkLoadResponse); 66 | 67 | rpc SecureBulkLoadHFiles(SecureBulkLoadHFilesRequest) 68 | returns (SecureBulkLoadHFilesResponse); 69 | 70 | rpc CleanupBulkLoad(CleanupBulkLoadRequest) 71 | returns (CleanupBulkLoadResponse); 72 | } 73 | -------------------------------------------------------------------------------- /protobuf/Snapshot.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 20 | option java_outer_classname = "SnapshotProtos"; 21 | option java_generic_services = true; 22 | option java_generate_equals_and_hash = true; 23 | option optimize_for = SPEED; 24 | 25 | import "FS.proto"; 26 | import "HBase.proto"; 27 | 28 | message SnapshotFileInfo { 29 | enum Type { 30 | HFILE = 1; 31 | WAL = 2; 32 | } 33 | 34 | required Type type = 1; 35 | 36 | optional string hfile = 3; 37 | 38 | optional string wal_server = 4; 39 | optional string wal_name = 5; 40 | } 41 | 42 | message SnapshotRegionManifest { 43 | optional int32 version = 1; 44 | 45 | required RegionInfo region_info = 2; 46 | repeated FamilyFiles family_files = 3; 47 | 48 | message StoreFile { 49 | required string name = 1; 50 | optional Reference reference = 2; 51 | 52 | // TODO: Add checksums or other fields to verify the file 53 | optional uint64 file_size = 3; 54 | } 55 | 56 | message FamilyFiles { 57 | required bytes family_name = 1; 58 | repeated StoreFile store_files = 2; 59 | } 60 | } 61 | 62 | message SnapshotDataManifest { 63 | required TableSchema table_schema = 1; 64 | repeated SnapshotRegionManifest region_manifests = 2; 65 | } 66 | -------------------------------------------------------------------------------- /protobuf/Tracing.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 20 | option java_outer_classname = "TracingProtos"; 21 | option java_generate_equals_and_hash = true; 22 | option optimize_for = SPEED; 23 | 24 | //Used to pass through the information necessary to continue 25 | //a trace after an RPC is made. All we need is the traceid 26 | //(so we know the overarching trace this message is a part of), and 27 | //the id of the current span when this message was sent, so we know 28 | //what span caused the new span we will create when this message is received. 29 | message RPCTInfo { 30 | optional int64 trace_id = 1; 31 | optional int64 parent_id = 2; 32 | } 33 | -------------------------------------------------------------------------------- /protobuf/VisibilityLabels.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 21 | option java_outer_classname = "VisibilityLabelsProtos"; 22 | option java_generic_services = true; 23 | option java_generate_equals_and_hash = true; 24 | option optimize_for = SPEED; 25 | 26 | import "Client.proto"; 27 | 28 | message VisibilityLabelsRequest { 29 | repeated VisibilityLabel visLabel = 1; 30 | } 31 | 32 | message VisibilityLabel { 33 | required bytes label = 1; 34 | optional uint32 ordinal = 2; 35 | } 36 | 37 | message VisibilityLabelsResponse { 38 | repeated RegionActionResult result = 1; 39 | } 40 | 41 | message SetAuthsRequest { 42 | required bytes user = 1; 43 | repeated bytes auth = 2; 44 | } 45 | 46 | message UserAuthorizations { 47 | required bytes user = 1; 48 | repeated uint32 auth = 2; 49 | } 50 | 51 | message MultiUserAuthorizations { 52 | repeated UserAuthorizations userAuths = 1; 53 | } 54 | 55 | message GetAuthsRequest { 56 | required bytes user = 1; 57 | } 58 | 59 | message GetAuthsResponse { 60 | required bytes user = 1; 61 | repeated bytes auth = 2; 62 | } 63 | 64 | message ListLabelsRequest { 65 | optional string regex = 1; 66 | } 67 | 68 | message ListLabelsResponse { 69 | repeated bytes label = 1; 70 | } 71 | 72 | service VisibilityLabelsService { 73 | rpc addLabels(VisibilityLabelsRequest) 74 | returns (VisibilityLabelsResponse); 75 | rpc setAuths(SetAuthsRequest) 76 | returns (VisibilityLabelsResponse); 77 | rpc clearAuths(SetAuthsRequest) 78 | returns (VisibilityLabelsResponse); 79 | rpc getAuths(GetAuthsRequest) 80 | returns (GetAuthsResponse); 81 | rpc listLabels(ListLabelsRequest) 82 | returns (ListLabelsResponse); 83 | } -------------------------------------------------------------------------------- /protobuf/WAL.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 20 | option java_outer_classname = "WALProtos"; 21 | option java_generic_services = false; 22 | option java_generate_equals_and_hash = true; 23 | option optimize_for = SPEED; 24 | 25 | import "HBase.proto"; 26 | 27 | message WALHeader { 28 | optional bool has_compression = 1; 29 | optional bytes encryption_key = 2; 30 | optional bool has_tag_compression = 3; 31 | optional string writer_cls_name = 4; 32 | optional string cell_codec_cls_name = 5; 33 | } 34 | 35 | // Protocol buffer version of HLogKey; see HLogKey comment, not really a key but WALEdit header for some KVs 36 | message WALKey { 37 | required bytes encoded_region_name = 1; 38 | required bytes table_name = 2; 39 | required uint64 log_sequence_number = 3; 40 | required uint64 write_time = 4; 41 | /* 42 | This parameter is deprecated in favor of clusters which 43 | contains the list of clusters that have consumed the change. 44 | It is retained so that the log created by earlier releases (0.94) 45 | can be read by the newer releases. 46 | */ 47 | optional UUID cluster_id = 5 [deprecated=true]; 48 | 49 | repeated FamilyScope scopes = 6; 50 | optional uint32 following_kv_count = 7; 51 | 52 | /* 53 | This field contains the list of clusters that have 54 | consumed the change 55 | */ 56 | repeated UUID cluster_ids = 8; 57 | 58 | optional uint64 nonceGroup = 9; 59 | optional uint64 nonce = 10; 60 | 61 | /* 62 | optional CustomEntryType custom_entry_type = 9; 63 | 64 | enum CustomEntryType { 65 | COMPACTION = 0; 66 | } 67 | */ 68 | } 69 | 70 | enum ScopeType { 71 | REPLICATION_SCOPE_LOCAL = 0; 72 | REPLICATION_SCOPE_GLOBAL = 1; 73 | } 74 | 75 | message FamilyScope { 76 | required bytes family = 1; 77 | required ScopeType scope_type = 2; 78 | } 79 | 80 | /** 81 | * Custom WAL entries 82 | */ 83 | 84 | /** 85 | * Special WAL entry to hold all related to a compaction. 86 | * Written to WAL before completing compaction. There is 87 | * sufficient info in the below message to complete later 88 | * the * compaction should we fail the WAL write. 89 | */ 90 | message CompactionDescriptor { 91 | required bytes table_name = 1; // TODO: WALKey already stores these, might remove 92 | required bytes encoded_region_name = 2; 93 | required bytes family_name = 3; 94 | repeated string compaction_input = 4; 95 | repeated string compaction_output = 5; 96 | required string store_home_dir = 6; 97 | optional bytes region_name = 7; // full region name 98 | } 99 | 100 | /** 101 | * A trailer that is appended to the end of a properly closed HLog WAL file. 102 | * If missing, this is either a legacy or a corrupted WAL file. 103 | */ 104 | message WALTrailer { 105 | } 106 | -------------------------------------------------------------------------------- /protobuf/ZooKeeper.proto: -------------------------------------------------------------------------------- 1 | package proto; 2 | /** 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | // ZNode data in hbase are serialized protobufs with a four byte 21 | // 'magic' 'PBUF' prefix. 22 | 23 | option java_package = "org.apache.hadoop.hbase.protobuf.generated"; 24 | option java_outer_classname = "ZooKeeperProtos"; 25 | option java_generic_services = true; 26 | option java_generate_equals_and_hash = true; 27 | option optimize_for = SPEED; 28 | 29 | import "HBase.proto"; 30 | import "ClusterStatus.proto"; 31 | 32 | /** 33 | * Content of the meta-region-server znode. 34 | */ 35 | message MetaRegionServer { 36 | // The ServerName hosting the meta region currently. 37 | required ServerName server = 1; 38 | // The major version of the rpc the server speaks. This is used so that 39 | // clients connecting to the cluster can have prior knowledge of what version 40 | // to send to a RegionServer. AsyncHBase will use this to detect versions. 41 | optional uint32 rpc_version = 2; 42 | // State of the region transition. OPEN means fully operational 'hbase:meta' 43 | optional RegionState.State state = 3; 44 | } 45 | 46 | /** 47 | * Content of the master znode. 48 | */ 49 | message Master { 50 | // The ServerName of the current Master 51 | required ServerName master = 1; 52 | // Major RPC version so that clients can know what version the master can accept. 53 | optional uint32 rpc_version = 2; 54 | } 55 | 56 | /** 57 | * Content of the '/hbase/running', cluster state, znode. 58 | */ 59 | message ClusterUp { 60 | // If this znode is present, cluster is up. Currently 61 | // the data is cluster start_date. 62 | required string start_date = 1; 63 | } 64 | 65 | /** 66 | * What we write under unassigned up in zookeeper as a region moves through 67 | * open/close, etc., regions. Details a region in transition. 68 | */ 69 | message RegionTransition { 70 | // Code for EventType gotten by doing o.a.h.h.EventHandler.EventType.getCode() 71 | required uint32 event_type_code = 1; 72 | // Full regionname in bytes 73 | required bytes region_name = 2; 74 | required uint64 create_time = 3; 75 | // The region server where the transition will happen or is happening 76 | required ServerName server_name = 4; 77 | optional bytes payload = 5; 78 | } 79 | 80 | /** 81 | * WAL SplitLog directory znodes have this for content. Used doing distributed 82 | * WAL splitting. Holds current state and name of server that originated split. 83 | */ 84 | message SplitLogTask { 85 | enum State { 86 | UNASSIGNED = 0; 87 | OWNED = 1; 88 | RESIGNED = 2; 89 | DONE = 3; 90 | ERR = 4; 91 | } 92 | enum RecoveryMode { 93 | UNKNOWN = 0; 94 | LOG_SPLITTING = 1; 95 | LOG_REPLAY = 2; 96 | } 97 | required State state = 1; 98 | required ServerName server_name = 2; 99 | optional RecoveryMode mode = 3 [default = UNKNOWN]; 100 | } 101 | 102 | /** 103 | * The znode that holds state of table. 104 | */ 105 | message Table { 106 | // Table's current state 107 | enum State { 108 | ENABLED = 0; 109 | DISABLED = 1; 110 | DISABLING = 2; 111 | ENABLING = 3; 112 | } 113 | // This is the table's state. If no znode for a table, 114 | // its state is presumed enabled. See o.a.h.h.zookeeper.ZKTable class 115 | // for more. 116 | required State state = 1 [default = ENABLED]; 117 | } 118 | 119 | /** 120 | * Used by replication. Holds a replication peer key. 121 | */ 122 | message ReplicationPeer { 123 | // clusterkey is the concatenation of the slave cluster's 124 | // hbase.zookeeper.quorum:hbase.zookeeper.property.clientPort:zookeeper.znode.parent 125 | required string clusterkey = 1; 126 | optional string replicationEndpointImpl = 2; 127 | repeated BytesBytesPair data = 3; 128 | repeated NameStringPair configuration = 4; 129 | } 130 | 131 | /** 132 | * Used by replication. Holds whether enabled or disabled 133 | */ 134 | message ReplicationState { 135 | enum State { 136 | ENABLED = 0; 137 | DISABLED = 1; 138 | } 139 | required State state = 1; 140 | } 141 | 142 | /** 143 | * Used by replication. Holds the current position in an HLog file. 144 | */ 145 | message ReplicationHLogPosition { 146 | required int64 position = 1; 147 | } 148 | 149 | /** 150 | * Used by replication. Used to lock a region server during failover. 151 | */ 152 | message ReplicationLock { 153 | required string lock_owner = 1; 154 | } 155 | 156 | /** 157 | * Metadata associated with a table lock in zookeeper 158 | */ 159 | message TableLock { 160 | optional TableName table_name = 1; 161 | optional ServerName lock_owner = 2; 162 | optional int64 thread_id = 3; 163 | optional bool is_shared = 4; 164 | optional string purpose = 5; 165 | optional int64 create_time = 6; 166 | } 167 | 168 | /** 169 | * sequence Id of a store 170 | */ 171 | message StoreSequenceId { 172 | required bytes family_name = 1; 173 | required uint64 sequence_id = 2; 174 | } 175 | 176 | /** 177 | * contains a sequence id of a region which should be the minimum of its store sequence ids and 178 | * list sequence ids of the region's stores 179 | */ 180 | message RegionStoreSequenceIds { 181 | required uint64 last_flushed_sequence_id = 1; 182 | repeated StoreSequenceId store_sequence_id = 2; 183 | } 184 | -------------------------------------------------------------------------------- /put.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bytes" 5 | "math" 6 | 7 | pb "github.com/golang/protobuf/proto" 8 | "github.com/pingcap/go-hbase/proto" 9 | ) 10 | 11 | type Put struct { 12 | Row []byte 13 | Families [][]byte 14 | Qualifiers [][][]byte 15 | Values [][][]byte 16 | Timestamp uint64 17 | } 18 | 19 | func NewPut(row []byte) *Put { 20 | return &Put{ 21 | Row: row, 22 | Families: make([][]byte, 0), 23 | Qualifiers: make([][][]byte, 0), 24 | Values: make([][][]byte, 0), 25 | } 26 | } 27 | 28 | func (p *Put) GetRow() []byte { 29 | return p.Row 30 | } 31 | 32 | func (p *Put) AddValue(family, qual, value []byte) *Put { 33 | pos := p.posOfFamily(family) 34 | if pos == -1 { 35 | p.Families = append(p.Families, family) 36 | p.Qualifiers = append(p.Qualifiers, make([][]byte, 0)) 37 | p.Values = append(p.Values, make([][]byte, 0)) 38 | 39 | pos = p.posOfFamily(family) 40 | } 41 | 42 | p.Qualifiers[pos] = append(p.Qualifiers[pos], qual) 43 | p.Values[pos] = append(p.Values[pos], value) 44 | return p 45 | } 46 | 47 | func (p *Put) AddStringValue(family, column, value string) *Put { 48 | return p.AddValue([]byte(family), []byte(column), []byte(value)) 49 | } 50 | 51 | func (p *Put) AddTimestamp(ts uint64) *Put { 52 | if ts == 0 { 53 | p.Timestamp = math.MaxInt64 54 | } else { 55 | p.Timestamp = ts 56 | } 57 | return p 58 | } 59 | 60 | func (p *Put) posOfFamily(family []byte) int { 61 | for p, v := range p.Families { 62 | if bytes.Equal(family, v) { 63 | return p 64 | } 65 | } 66 | return -1 67 | } 68 | 69 | func (p *Put) ToProto() pb.Message { 70 | put := &proto.MutationProto{ 71 | Row: p.Row, 72 | MutateType: proto.MutationProto_PUT.Enum(), 73 | } 74 | 75 | for i, family := range p.Families { 76 | cv := &proto.MutationProto_ColumnValue{ 77 | Family: family, 78 | } 79 | 80 | for j := range p.Qualifiers[i] { 81 | cv.QualifierValue = append(cv.QualifierValue, &proto.MutationProto_ColumnValue_QualifierValue{ 82 | Qualifier: p.Qualifiers[i][j], 83 | Value: p.Values[i][j], 84 | Timestamp: pb.Uint64(p.Timestamp), 85 | }) 86 | } 87 | 88 | put.ColumnValue = append(put.ColumnValue, cv) 89 | } 90 | 91 | return put 92 | } 93 | -------------------------------------------------------------------------------- /put_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bytes" 5 | 6 | . "github.com/pingcap/check" 7 | "github.com/pingcap/go-hbase/proto" 8 | ) 9 | 10 | type HBasePutTestSuit struct { 11 | cli HBaseClient 12 | tableName string 13 | } 14 | 15 | var _ = Suite(&HBasePutTestSuit{}) 16 | 17 | func (s *HBasePutTestSuit) SetUpTest(c *C) { 18 | var err error 19 | s.cli, err = NewClient(getTestZkHosts(), "/hbase") 20 | c.Assert(err, IsNil) 21 | 22 | s.tableName = "t2" 23 | tblDesc := NewTableDesciptor(s.tableName) 24 | cf := NewColumnFamilyDescriptor("cf") 25 | tblDesc.AddColumnDesc(cf) 26 | err = s.cli.CreateTable(tblDesc, nil) 27 | c.Assert(err, IsNil) 28 | } 29 | 30 | func (s *HBasePutTestSuit) TearDownTest(c *C) { 31 | err := s.cli.DisableTable(s.tableName) 32 | c.Assert(err, IsNil) 33 | 34 | err = s.cli.DropTable(s.tableName) 35 | c.Assert(err, IsNil) 36 | } 37 | 38 | func (s *HBasePutTestSuit) TestPut(c *C) { 39 | g := NewPut([]byte("row")) 40 | g.AddValue([]byte("cf"), []byte("q"), []byte("val")) 41 | msg := g.ToProto() 42 | p, _ := msg.(*proto.MutationProto) 43 | 44 | c.Assert(*p.MutateType, Equals, *proto.MutationProto_PUT.Enum()) 45 | 46 | for _, col := range p.ColumnValue { 47 | for _, v := range col.QualifierValue { 48 | c.Assert(bytes.Compare([]byte("q"), v.Qualifier), Equals, 0) 49 | c.Assert(bytes.Compare([]byte("val"), v.Value), Equals, 0) 50 | } 51 | } 52 | } 53 | 54 | func (s *HBasePutTestSuit) TestGetPut(c *C) { 55 | p := NewPut([]byte("1_\xff\xff")) 56 | p2 := NewPut([]byte("1_\xff\xfe")) 57 | p3 := NewPut([]byte("1_\xff\xee")) 58 | p.AddValue([]byte("cf"), []byte("q"), []byte("!")) 59 | p2.AddValue([]byte("cf"), []byte("q"), []byte("!")) 60 | p3.AddValue([]byte("cf"), []byte("q"), []byte("!")) 61 | 62 | cli, err := NewClient(getTestZkHosts(), "/hbase") 63 | c.Assert(err, Equals, nil) 64 | 65 | ok, err := cli.Put(s.tableName, p) 66 | c.Assert(ok, IsTrue) 67 | c.Assert(err, IsNil) 68 | 69 | ok, err = cli.Put(s.tableName, p2) 70 | c.Assert(ok, IsTrue) 71 | c.Assert(err, IsNil) 72 | 73 | ok, err = cli.Put(s.tableName, p3) 74 | c.Assert(ok, IsTrue) 75 | c.Assert(err, IsNil) 76 | 77 | scan := NewScan([]byte(s.tableName), 100, cli) 78 | scan.StartRow = []byte("1_") 79 | for { 80 | r := scan.Next() 81 | if r == nil { 82 | break 83 | } 84 | } 85 | 86 | ok, err = cli.Delete(s.tableName, NewDelete([]byte("1_\xff\xff"))) 87 | c.Assert(ok, IsTrue) 88 | c.Assert(err, IsNil) 89 | 90 | ok, err = cli.Delete(s.tableName, NewDelete([]byte("1_\xff\xfe"))) 91 | c.Assert(ok, IsTrue) 92 | c.Assert(err, IsNil) 93 | 94 | ok, err = cli.Delete(s.tableName, NewDelete([]byte("1_\xff\xee"))) 95 | c.Assert(ok, IsTrue) 96 | c.Assert(err, IsNil) 97 | } 98 | -------------------------------------------------------------------------------- /result.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/pingcap/go-hbase/proto" 7 | ) 8 | 9 | type Kv struct { 10 | Row []byte 11 | Ts uint64 12 | Value []byte 13 | // history results 14 | Values map[uint64][]byte 15 | Column 16 | } 17 | 18 | func (kv *Kv) String() string { 19 | if kv == nil { 20 | return "" 21 | } 22 | return fmt.Sprintf("Kv(%+v)", *kv) 23 | } 24 | 25 | type ResultRow struct { 26 | Row []byte 27 | Columns map[string]*Kv 28 | SortedColumns []*Kv 29 | } 30 | 31 | func (r *ResultRow) String() string { 32 | if r == nil { 33 | return "" 34 | } 35 | return fmt.Sprintf("ResultRow(%+v)", *r) 36 | } 37 | 38 | func NewResultRow(result *proto.Result) *ResultRow { 39 | // empty response 40 | if len(result.GetCell()) == 0 { 41 | return nil 42 | } 43 | res := &ResultRow{} 44 | res.Columns = make(map[string]*Kv) 45 | res.SortedColumns = make([]*Kv, 0) 46 | 47 | for _, cell := range result.GetCell() { 48 | res.Row = cell.GetRow() 49 | 50 | col := &Kv{ 51 | Row: res.Row, 52 | Column: Column{ 53 | Family: cell.GetFamily(), 54 | Qual: cell.GetQualifier(), 55 | }, 56 | Value: cell.GetValue(), 57 | Ts: cell.GetTimestamp(), 58 | } 59 | 60 | colName := string(col.Column.Family) + ":" + string(col.Column.Qual) 61 | 62 | if v, exists := res.Columns[colName]; exists { 63 | // renew the same cf result 64 | if col.Ts > v.Ts { 65 | v.Value = col.Value 66 | v.Ts = col.Ts 67 | } 68 | v.Values[col.Ts] = col.Value 69 | } else { 70 | col.Values = map[uint64][]byte{col.Ts: col.Value} 71 | res.Columns[colName] = col 72 | res.SortedColumns = append(res.SortedColumns, col) 73 | } 74 | } 75 | return res 76 | } 77 | -------------------------------------------------------------------------------- /result_test.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "strconv" 5 | 6 | pb "github.com/golang/protobuf/proto" 7 | . "github.com/pingcap/check" 8 | "github.com/pingcap/go-hbase/proto" 9 | ) 10 | 11 | type ResultTestSuit struct{} 12 | 13 | var _ = Suite(&ResultTestSuit{}) 14 | 15 | func (s *ResultTestSuit) TestResultRow(c *C) { 16 | var cells []*proto.Cell 17 | for i := 1; i <= 10; i++ { 18 | cell := &proto.Cell{ 19 | Row: []byte("row"), 20 | Family: []byte("cf"), 21 | Qualifier: []byte("q"), 22 | Timestamp: pb.Uint64(uint64(i)), 23 | CellType: proto.CellType_PUT.Enum(), 24 | Value: []byte(strconv.Itoa(i)), 25 | } 26 | cells = append(cells, cell) 27 | } 28 | r := &proto.Result{ 29 | Cell: cells, 30 | } 31 | 32 | rr := NewResultRow(r) 33 | c.Assert(rr.SortedColumns, HasLen, 1) 34 | c.Assert(rr.SortedColumns[0].Values, HasLen, 10) 35 | c.Assert(string(rr.SortedColumns[0].Value), Equals, "10") 36 | } 37 | -------------------------------------------------------------------------------- /service_call.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "github.com/pingcap/go-hbase/proto" 5 | pb "github.com/golang/protobuf/proto" 6 | ) 7 | 8 | type CoprocessorServiceCall struct { 9 | Row []byte 10 | ServiceName string 11 | MethodName string 12 | RequestParam []byte 13 | } 14 | 15 | func (c *CoprocessorServiceCall) ToProto() pb.Message { 16 | return &proto.CoprocessorServiceCall{ 17 | Row: c.Row, 18 | ServiceName: pb.String(c.ServiceName), 19 | MethodName: pb.String(c.MethodName), 20 | Request: c.RequestParam, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /types.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import "bytes" 4 | 5 | type Type byte 6 | 7 | const ( 8 | TypeMinimum = Type(0) 9 | TypePut = Type(4) 10 | TypeDelete = Type(8) 11 | TypeDeleteFamilyVersion = Type(10) 12 | TypeDeleteColumn = Type(12) 13 | TypeDeleteFamily = Type(14) 14 | TypeMaximum = Type(0xff) 15 | ) 16 | 17 | type set map[string]struct{} 18 | 19 | func newSet() set { 20 | return set(map[string]struct{}{}) 21 | } 22 | 23 | func (s set) exists(k string) bool { 24 | _, ok := s[k] 25 | return ok 26 | } 27 | 28 | func (s set) add(k string) { 29 | s[k] = struct{}{} 30 | } 31 | 32 | func (s set) remove(k string) { 33 | delete(s, k) 34 | } 35 | 36 | type BytesSlice [][]byte 37 | 38 | func (s BytesSlice) Len() int { return len(s) } 39 | func (s BytesSlice) Less(i, j int) bool { return bytes.Compare(s[i], s[j]) < 0 } 40 | func (s BytesSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 41 | -------------------------------------------------------------------------------- /utils.go: -------------------------------------------------------------------------------- 1 | package hbase 2 | 3 | import ( 4 | "bytes" 5 | "time" 6 | 7 | "github.com/juju/errors" 8 | "github.com/pingcap/go-hbase/proto" 9 | ) 10 | 11 | func retrySleep(retries int) { 12 | time.Sleep(time.Duration(retries*500) * time.Millisecond) 13 | } 14 | 15 | func findKey(region *RegionInfo, key []byte) bool { 16 | if region == nil { 17 | return false 18 | } 19 | // StartKey <= key < EndKey 20 | return (len(region.StartKey) == 0 || bytes.Compare(region.StartKey, key) <= 0) && 21 | (len(region.EndKey) == 0 || bytes.Compare(key, region.EndKey) < 0) 22 | } 23 | 24 | func NewRegionSpecifier(regionName string) *proto.RegionSpecifier { 25 | return &proto.RegionSpecifier{ 26 | Type: proto.RegionSpecifier_REGION_NAME.Enum(), 27 | Value: []byte(regionName), 28 | } 29 | } 30 | 31 | // TODO: The following functions can be moved later. 32 | // ErrorEqual returns a boolean indicating whether err1 is equal to err2. 33 | func ErrorEqual(err1, err2 error) bool { 34 | e1 := errors.Cause(err1) 35 | e2 := errors.Cause(err2) 36 | 37 | if e1 == e2 { 38 | return true 39 | } 40 | 41 | if e1 == nil || e2 == nil { 42 | return e1 == e2 43 | } 44 | 45 | return e1.Error() == e2.Error() 46 | } 47 | 48 | // ErrorNotEqual returns a boolean indicating whether err1 isn't equal to err2. 49 | func ErrorNotEqual(err1, err2 error) bool { 50 | return !ErrorEqual(err1, err2) 51 | } 52 | --------------------------------------------------------------------------------