rbhive 0.2.95 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENSE +20 -0
- data/README.md +204 -0
- data/lib/rbhive/connection.rb +2 -1
- data/lib/rbhive/t_c_l_i_connection.rb +315 -0
- data/lib/rbhive/t_c_l_i_result_set.rb +3 -0
- data/lib/rbhive/t_c_l_i_schema_definition.rb +87 -0
- data/lib/rbhive/version.rb +3 -0
- data/lib/rbhive.rb +4 -1
- data/lib/thrift/facebook_service.rb +4 -5
- data/lib/thrift/fb303_constants.rb +3 -2
- data/lib/thrift/fb303_types.rb +2 -1
- data/lib/thrift/hive_metastore_constants.rb +3 -3
- data/lib/thrift/hive_metastore_types.rb +176 -14
- data/lib/thrift/hive_service_constants.rb +7 -2
- data/lib/thrift/hive_service_types.rb +53 -48
- data/lib/thrift/queryplan_constants.rb +7 -2
- data/lib/thrift/queryplan_types.rb +225 -217
- data/lib/thrift/sasl_client_transport.rb +97 -0
- data/lib/thrift/serde_constants.rb +5 -3
- data/lib/thrift/serde_types.rb +2 -2
- data/lib/thrift/t_c_l_i_service.rb +892 -0
- data/lib/thrift/t_c_l_i_service_constants.rb +66 -0
- data/lib/thrift/t_c_l_i_service_types.rb +1469 -0
- data/lib/thrift/thrift_hive.rb +405 -401
- data/lib/thrift/thrift_hive_metastore.rb +1452 -203
- data/rbhive.gemspec +24 -0
- metadata +90 -69
- data/lib/thrift/reflection_limited_constants.rb +0 -8
- data/lib/thrift/reflection_limited_types.rb +0 -150
@@ -1,253 +1,261 @@
|
|
1
1
|
#
|
2
|
-
# Autogenerated by Thrift
|
2
|
+
# Autogenerated by Thrift Compiler (0.9.0)
|
3
3
|
#
|
4
4
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
5
|
#
|
6
6
|
|
7
|
+
require 'thrift'
|
7
8
|
|
8
|
-
module
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
module Hive
|
10
|
+
module Thrift
|
11
|
+
module AdjacencyType
|
12
|
+
CONJUNCTIVE = 0
|
13
|
+
DISJUNCTIVE = 1
|
14
|
+
VALUE_MAP = {0 => "CONJUNCTIVE", 1 => "DISJUNCTIVE"}
|
15
|
+
VALID_VALUES = Set.new([CONJUNCTIVE, DISJUNCTIVE]).freeze
|
16
|
+
end
|
14
17
|
|
15
|
-
module NodeType
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
18
|
+
module NodeType
|
19
|
+
OPERATOR = 0
|
20
|
+
STAGE = 1
|
21
|
+
VALUE_MAP = {0 => "OPERATOR", 1 => "STAGE"}
|
22
|
+
VALID_VALUES = Set.new([OPERATOR, STAGE]).freeze
|
23
|
+
end
|
21
24
|
|
22
|
-
module OperatorType
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
module OperatorType
|
26
|
+
JOIN = 0
|
27
|
+
MAPJOIN = 1
|
28
|
+
EXTRACT = 2
|
29
|
+
FILTER = 3
|
30
|
+
FORWARD = 4
|
31
|
+
GROUPBY = 5
|
32
|
+
LIMIT = 6
|
33
|
+
SCRIPT = 7
|
34
|
+
SELECT = 8
|
35
|
+
TABLESCAN = 9
|
36
|
+
FILESINK = 10
|
37
|
+
REDUCESINK = 11
|
38
|
+
UNION = 12
|
39
|
+
UDTF = 13
|
40
|
+
LATERALVIEWJOIN = 14
|
41
|
+
LATERALVIEWFORWARD = 15
|
42
|
+
HASHTABLESINK = 16
|
43
|
+
HASHTABLEDUMMY = 17
|
44
|
+
VALUE_MAP = {0 => "JOIN", 1 => "MAPJOIN", 2 => "EXTRACT", 3 => "FILTER", 4 => "FORWARD", 5 => "GROUPBY", 6 => "LIMIT", 7 => "SCRIPT", 8 => "SELECT", 9 => "TABLESCAN", 10 => "FILESINK", 11 => "REDUCESINK", 12 => "UNION", 13 => "UDTF", 14 => "LATERALVIEWJOIN", 15 => "LATERALVIEWFORWARD", 16 => "HASHTABLESINK", 17 => "HASHTABLEDUMMY"}
|
45
|
+
VALID_VALUES = Set.new([JOIN, MAPJOIN, EXTRACT, FILTER, FORWARD, GROUPBY, LIMIT, SCRIPT, SELECT, TABLESCAN, FILESINK, REDUCESINK, UNION, UDTF, LATERALVIEWJOIN, LATERALVIEWFORWARD, HASHTABLESINK, HASHTABLEDUMMY]).freeze
|
46
|
+
end
|
42
47
|
|
43
|
-
module TaskType
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
48
|
+
module TaskType
|
49
|
+
MAP = 0
|
50
|
+
REDUCE = 1
|
51
|
+
OTHER = 2
|
52
|
+
VALUE_MAP = {0 => "MAP", 1 => "REDUCE", 2 => "OTHER"}
|
53
|
+
VALID_VALUES = Set.new([MAP, REDUCE, OTHER]).freeze
|
54
|
+
end
|
50
55
|
|
51
|
-
module StageType
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
module StageType
|
57
|
+
CONDITIONAL = 0
|
58
|
+
COPY = 1
|
59
|
+
DDL = 2
|
60
|
+
MAPRED = 3
|
61
|
+
EXPLAIN = 4
|
62
|
+
FETCH = 5
|
63
|
+
FUNC = 6
|
64
|
+
MAPREDLOCAL = 7
|
65
|
+
MOVE = 8
|
66
|
+
STATS = 9
|
67
|
+
VALUE_MAP = {0 => "CONDITIONAL", 1 => "COPY", 2 => "DDL", 3 => "MAPRED", 4 => "EXPLAIN", 5 => "FETCH", 6 => "FUNC", 7 => "MAPREDLOCAL", 8 => "MOVE", 9 => "STATS"}
|
68
|
+
VALID_VALUES = Set.new([CONDITIONAL, COPY, DDL, MAPRED, EXPLAIN, FETCH, FUNC, MAPREDLOCAL, MOVE, STATS]).freeze
|
69
|
+
end
|
64
70
|
|
65
|
-
class Adjacency
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
class Adjacency
|
72
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
73
|
+
NODE = 1
|
74
|
+
CHILDREN = 2
|
75
|
+
ADJACENCYTYPE = 3
|
70
76
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
77
|
+
FIELDS = {
|
78
|
+
NODE => {:type => ::Thrift::Types::STRING, :name => 'node'},
|
79
|
+
CHILDREN => {:type => ::Thrift::Types::LIST, :name => 'children', :element => {:type => ::Thrift::Types::STRING}},
|
80
|
+
ADJACENCYTYPE => {:type => ::Thrift::Types::I32, :name => 'adjacencyType', :enum_class => ::Hive::Thrift::AdjacencyType}
|
81
|
+
}
|
76
82
|
|
77
|
-
|
83
|
+
def struct_fields; FIELDS; end
|
78
84
|
|
79
|
-
|
80
|
-
|
81
|
-
|
85
|
+
def validate
|
86
|
+
unless @adjacencyType.nil? || ::Hive::Thrift::AdjacencyType::VALID_VALUES.include?(@adjacencyType)
|
87
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field adjacencyType!')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
::Thrift::Struct.generate_accessors self
|
82
92
|
end
|
83
|
-
end
|
84
93
|
|
85
|
-
|
86
|
-
|
94
|
+
class Graph
|
95
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
96
|
+
NODETYPE = 1
|
97
|
+
ROOTS = 2
|
98
|
+
ADJACENCYLIST = 3
|
87
99
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
100
|
+
FIELDS = {
|
101
|
+
NODETYPE => {:type => ::Thrift::Types::I32, :name => 'nodeType', :enum_class => ::Hive::Thrift::NodeType},
|
102
|
+
ROOTS => {:type => ::Thrift::Types::LIST, :name => 'roots', :element => {:type => ::Thrift::Types::STRING}},
|
103
|
+
ADJACENCYLIST => {:type => ::Thrift::Types::LIST, :name => 'adjacencyList', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Hive::Thrift::Adjacency}}
|
104
|
+
}
|
93
105
|
|
94
|
-
|
95
|
-
NODETYPE => {:type => ::Thrift::Types::I32, :name => 'nodeType', :enum_class => NodeType},
|
96
|
-
ROOTS => {:type => ::Thrift::Types::LIST, :name => 'roots', :element => {:type => ::Thrift::Types::STRING}},
|
97
|
-
ADJACENCYLIST => {:type => ::Thrift::Types::LIST, :name => 'adjacencyList', :element => {:type => ::Thrift::Types::STRUCT, :class => Adjacency}}
|
98
|
-
}
|
106
|
+
def struct_fields; FIELDS; end
|
99
107
|
|
100
|
-
|
108
|
+
def validate
|
109
|
+
unless @nodeType.nil? || ::Hive::Thrift::NodeType::VALID_VALUES.include?(@nodeType)
|
110
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field nodeType!')
|
111
|
+
end
|
112
|
+
end
|
101
113
|
|
102
|
-
|
103
|
-
unless @nodeType.nil? || NodeType::VALID_VALUES.include?(@nodeType)
|
104
|
-
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field nodeType!')
|
114
|
+
::Thrift::Struct.generate_accessors self
|
105
115
|
end
|
106
|
-
end
|
107
|
-
|
108
|
-
::Thrift::Struct.generate_accessors self
|
109
|
-
end
|
110
116
|
|
111
|
-
class Operator
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
117
|
+
class Operator
|
118
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
119
|
+
OPERATORID = 1
|
120
|
+
OPERATORTYPE = 2
|
121
|
+
OPERATORATTRIBUTES = 3
|
122
|
+
OPERATORCOUNTERS = 4
|
123
|
+
DONE = 5
|
124
|
+
STARTED = 6
|
125
|
+
|
126
|
+
FIELDS = {
|
127
|
+
OPERATORID => {:type => ::Thrift::Types::STRING, :name => 'operatorId'},
|
128
|
+
OPERATORTYPE => {:type => ::Thrift::Types::I32, :name => 'operatorType', :enum_class => ::Hive::Thrift::OperatorType},
|
129
|
+
OPERATORATTRIBUTES => {:type => ::Thrift::Types::MAP, :name => 'operatorAttributes', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
|
130
|
+
OPERATORCOUNTERS => {:type => ::Thrift::Types::MAP, :name => 'operatorCounters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}},
|
131
|
+
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
132
|
+
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
133
|
+
}
|
134
|
+
|
135
|
+
def struct_fields; FIELDS; end
|
136
|
+
|
137
|
+
def validate
|
138
|
+
unless @operatorType.nil? || ::Hive::Thrift::OperatorType::VALID_VALUES.include?(@operatorType)
|
139
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field operatorType!')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
::Thrift::Struct.generate_accessors self
|
134
144
|
end
|
135
|
-
end
|
136
|
-
|
137
|
-
::Thrift::Struct.generate_accessors self
|
138
|
-
end
|
139
145
|
|
140
|
-
class Task
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
146
|
+
class Task
|
147
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
148
|
+
TASKID = 1
|
149
|
+
TASKTYPE = 2
|
150
|
+
TASKATTRIBUTES = 3
|
151
|
+
TASKCOUNTERS = 4
|
152
|
+
OPERATORGRAPH = 5
|
153
|
+
OPERATORLIST = 6
|
154
|
+
DONE = 7
|
155
|
+
STARTED = 8
|
156
|
+
|
157
|
+
FIELDS = {
|
158
|
+
TASKID => {:type => ::Thrift::Types::STRING, :name => 'taskId'},
|
159
|
+
TASKTYPE => {:type => ::Thrift::Types::I32, :name => 'taskType', :enum_class => ::Hive::Thrift::TaskType},
|
160
|
+
TASKATTRIBUTES => {:type => ::Thrift::Types::MAP, :name => 'taskAttributes', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
|
161
|
+
TASKCOUNTERS => {:type => ::Thrift::Types::MAP, :name => 'taskCounters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}},
|
162
|
+
OPERATORGRAPH => {:type => ::Thrift::Types::STRUCT, :name => 'operatorGraph', :class => ::Hive::Thrift::Graph, :optional => true},
|
163
|
+
OPERATORLIST => {:type => ::Thrift::Types::LIST, :name => 'operatorList', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Hive::Thrift::Operator}, :optional => true},
|
164
|
+
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
165
|
+
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
166
|
+
}
|
167
|
+
|
168
|
+
def struct_fields; FIELDS; end
|
169
|
+
|
170
|
+
def validate
|
171
|
+
unless @taskType.nil? || ::Hive::Thrift::TaskType::VALID_VALUES.include?(@taskType)
|
172
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field taskType!')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
::Thrift::Struct.generate_accessors self
|
167
177
|
end
|
168
|
-
end
|
169
|
-
|
170
|
-
::Thrift::Struct.generate_accessors self
|
171
|
-
end
|
172
178
|
|
173
|
-
class Stage
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
179
|
+
class Stage
|
180
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
181
|
+
STAGEID = 1
|
182
|
+
STAGETYPE = 2
|
183
|
+
STAGEATTRIBUTES = 3
|
184
|
+
STAGECOUNTERS = 4
|
185
|
+
TASKLIST = 5
|
186
|
+
DONE = 6
|
187
|
+
STARTED = 7
|
188
|
+
|
189
|
+
FIELDS = {
|
190
|
+
STAGEID => {:type => ::Thrift::Types::STRING, :name => 'stageId'},
|
191
|
+
STAGETYPE => {:type => ::Thrift::Types::I32, :name => 'stageType', :enum_class => ::Hive::Thrift::StageType},
|
192
|
+
STAGEATTRIBUTES => {:type => ::Thrift::Types::MAP, :name => 'stageAttributes', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
|
193
|
+
STAGECOUNTERS => {:type => ::Thrift::Types::MAP, :name => 'stageCounters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}},
|
194
|
+
TASKLIST => {:type => ::Thrift::Types::LIST, :name => 'taskList', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Hive::Thrift::Task}},
|
195
|
+
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
196
|
+
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
197
|
+
}
|
198
|
+
|
199
|
+
def struct_fields; FIELDS; end
|
200
|
+
|
201
|
+
def validate
|
202
|
+
unless @stageType.nil? || ::Hive::Thrift::StageType::VALID_VALUES.include?(@stageType)
|
203
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field stageType!')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
::Thrift::Struct.generate_accessors self
|
198
208
|
end
|
199
|
-
end
|
200
209
|
|
201
|
-
|
202
|
-
|
210
|
+
class Query
|
211
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
212
|
+
QUERYID = 1
|
213
|
+
QUERYTYPE = 2
|
214
|
+
QUERYATTRIBUTES = 3
|
215
|
+
QUERYCOUNTERS = 4
|
216
|
+
STAGEGRAPH = 5
|
217
|
+
STAGELIST = 6
|
218
|
+
DONE = 7
|
219
|
+
STARTED = 8
|
220
|
+
|
221
|
+
FIELDS = {
|
222
|
+
QUERYID => {:type => ::Thrift::Types::STRING, :name => 'queryId'},
|
223
|
+
QUERYTYPE => {:type => ::Thrift::Types::STRING, :name => 'queryType'},
|
224
|
+
QUERYATTRIBUTES => {:type => ::Thrift::Types::MAP, :name => 'queryAttributes', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
|
225
|
+
QUERYCOUNTERS => {:type => ::Thrift::Types::MAP, :name => 'queryCounters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}},
|
226
|
+
STAGEGRAPH => {:type => ::Thrift::Types::STRUCT, :name => 'stageGraph', :class => ::Hive::Thrift::Graph},
|
227
|
+
STAGELIST => {:type => ::Thrift::Types::LIST, :name => 'stageList', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Hive::Thrift::Stage}},
|
228
|
+
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
229
|
+
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
230
|
+
}
|
231
|
+
|
232
|
+
def struct_fields; FIELDS; end
|
233
|
+
|
234
|
+
def validate
|
235
|
+
end
|
236
|
+
|
237
|
+
::Thrift::Struct.generate_accessors self
|
238
|
+
end
|
203
239
|
|
204
|
-
class
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
QUERYCOUNTERS = 4
|
210
|
-
STAGEGRAPH = 5
|
211
|
-
STAGELIST = 6
|
212
|
-
DONE = 7
|
213
|
-
STARTED = 8
|
214
|
-
|
215
|
-
FIELDS = {
|
216
|
-
QUERYID => {:type => ::Thrift::Types::STRING, :name => 'queryId'},
|
217
|
-
QUERYTYPE => {:type => ::Thrift::Types::STRING, :name => 'queryType'},
|
218
|
-
QUERYATTRIBUTES => {:type => ::Thrift::Types::MAP, :name => 'queryAttributes', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}},
|
219
|
-
QUERYCOUNTERS => {:type => ::Thrift::Types::MAP, :name => 'queryCounters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}},
|
220
|
-
STAGEGRAPH => {:type => ::Thrift::Types::STRUCT, :name => 'stageGraph', :class => Graph},
|
221
|
-
STAGELIST => {:type => ::Thrift::Types::LIST, :name => 'stageList', :element => {:type => ::Thrift::Types::STRUCT, :class => Stage}},
|
222
|
-
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
223
|
-
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
224
|
-
}
|
225
|
-
|
226
|
-
def struct_fields; FIELDS; end
|
227
|
-
|
228
|
-
def validate
|
229
|
-
end
|
240
|
+
class QueryPlan
|
241
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
242
|
+
QUERIES = 1
|
243
|
+
DONE = 2
|
244
|
+
STARTED = 3
|
230
245
|
|
231
|
-
|
232
|
-
|
246
|
+
FIELDS = {
|
247
|
+
QUERIES => {:type => ::Thrift::Types::LIST, :name => 'queries', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Hive::Thrift::Query}},
|
248
|
+
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
249
|
+
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
250
|
+
}
|
233
251
|
|
234
|
-
|
235
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
236
|
-
QUERIES = 1
|
237
|
-
DONE = 2
|
238
|
-
STARTED = 3
|
252
|
+
def struct_fields; FIELDS; end
|
239
253
|
|
240
|
-
|
241
|
-
|
242
|
-
DONE => {:type => ::Thrift::Types::BOOL, :name => 'done'},
|
243
|
-
STARTED => {:type => ::Thrift::Types::BOOL, :name => 'started'}
|
244
|
-
}
|
254
|
+
def validate
|
255
|
+
end
|
245
256
|
|
246
|
-
|
257
|
+
::Thrift::Struct.generate_accessors self
|
258
|
+
end
|
247
259
|
|
248
|
-
def validate
|
249
260
|
end
|
250
|
-
|
251
|
-
::Thrift::Struct.generate_accessors self
|
252
261
|
end
|
253
|
-
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Thrift
|
2
|
+
class SaslClientTransport < BufferedTransport
|
3
|
+
attr_reader :challenge
|
4
|
+
|
5
|
+
STATUS_BYTES = 1
|
6
|
+
PAYLOAD_LENGTH_BYTES = 4
|
7
|
+
AUTH_MECHANISM = 'PLAIN'
|
8
|
+
NEGOTIATION_STATUS = {
|
9
|
+
START: 0x01,
|
10
|
+
OK: 0x02,
|
11
|
+
BAD: 0x03,
|
12
|
+
ERROR: 0x04,
|
13
|
+
COMPLETE: 0x05
|
14
|
+
}
|
15
|
+
|
16
|
+
def initialize(transport, sasl_params={})
|
17
|
+
super(transport)
|
18
|
+
@challenge = nil
|
19
|
+
@sasl_username = sasl_params.fetch(:username, 'anonymous')
|
20
|
+
@sasl_password = sasl_params.fetch(:password, 'anonymous')
|
21
|
+
end
|
22
|
+
|
23
|
+
def read(sz)
|
24
|
+
len, = @transport.read(PAYLOAD_LENGTH_BYTES).unpack('l>') if @rbuf.nil?
|
25
|
+
sz = len if len && sz > len
|
26
|
+
@index += sz
|
27
|
+
ret = @rbuf.slice(@index - sz, sz) || Bytes.empty_byte_buffer
|
28
|
+
if ret.length == 0
|
29
|
+
@rbuf = @transport.read(len) rescue Bytes.empty_byte_buffer
|
30
|
+
@index = sz
|
31
|
+
ret = @rbuf.slice(0, sz) || Bytes.empty_byte_buffer
|
32
|
+
end
|
33
|
+
ret
|
34
|
+
end
|
35
|
+
|
36
|
+
def read_byte
|
37
|
+
reset_buffer! if @index >= @rbuf.size
|
38
|
+
@index += 1
|
39
|
+
Bytes.get_string_byte(@rbuf, @index - 1)
|
40
|
+
end
|
41
|
+
|
42
|
+
def read_into_buffer(buffer, size)
|
43
|
+
i = 0
|
44
|
+
while i < size
|
45
|
+
reset_buffer! if @index >= @rbuf.size
|
46
|
+
byte = Bytes.get_string_byte(@rbuf, @index)
|
47
|
+
Bytes.set_string_byte(buffer, i, byte)
|
48
|
+
@index += 1
|
49
|
+
i += 1
|
50
|
+
end
|
51
|
+
i
|
52
|
+
end
|
53
|
+
|
54
|
+
def write(buf)
|
55
|
+
initiate_hand_shake if @challenge.nil?
|
56
|
+
header = [buf.length].pack('l>')
|
57
|
+
@wbuf << (header + Bytes.force_binary_encoding(buf))
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
|
62
|
+
def initiate_hand_shake
|
63
|
+
header = [NEGOTIATION_STATUS[:START], AUTH_MECHANISM.length].pack('cl>')
|
64
|
+
@transport.write header + AUTH_MECHANISM
|
65
|
+
message = "[#{AUTH_MECHANISM}]\u0000#{@sasl_username}\u0000#{@sasl_password}"
|
66
|
+
header = [NEGOTIATION_STATUS[:OK], message.length].pack('cl>')
|
67
|
+
@transport.write header + message
|
68
|
+
status, len = @transport.read(STATUS_BYTES + PAYLOAD_LENGTH_BYTES).unpack('cl>')
|
69
|
+
case status
|
70
|
+
when NEGOTIATION_STATUS[:BAD], NEGOTIATION_STATUS[:ERROR]
|
71
|
+
raise @transport.to_io.read(len)
|
72
|
+
when NEGOTIATION_STATUS[:COMPLETE]
|
73
|
+
@challenge = @transport.to_io.read len
|
74
|
+
when NEGOTIATION_STATUS[:OK]
|
75
|
+
raise "Failed to complete challenge exchange: only NONE supported currently"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def reset_buffer!
|
82
|
+
len, = @transport.read(PAYLOAD_LENGTH_BYTES).unpack('l>')
|
83
|
+
@rbuf = @transport.read(len)
|
84
|
+
while @rbuf.size < len
|
85
|
+
@rbuf << @transport.read(len - @rbuf.size)
|
86
|
+
end
|
87
|
+
@index = 0
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class SaslClientTransportFactory < BaseTransportFactory
|
92
|
+
def get_transport(transport)
|
93
|
+
return SaslClientTransport.new(transport)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
#
|
2
|
-
# Autogenerated by Thrift
|
2
|
+
# Autogenerated by Thrift Compiler (0.9.0)
|
3
3
|
#
|
4
4
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
5
|
#
|
6
6
|
|
7
|
-
require
|
7
|
+
require 'thrift'
|
8
|
+
require 'serde_types'
|
8
9
|
|
9
10
|
SERIALIZATION_LIB = %q"serialization.lib"
|
10
11
|
|
@@ -64,6 +65,8 @@ MAP_TYPE_NAME = %q"map"
|
|
64
65
|
|
65
66
|
STRUCT_TYPE_NAME = %q"struct"
|
66
67
|
|
68
|
+
UNION_TYPE_NAME = %q"uniontype"
|
69
|
+
|
67
70
|
LIST_COLUMNS = %q"columns"
|
68
71
|
|
69
72
|
LIST_COLUMN_TYPES = %q"columns.types"
|
@@ -87,4 +90,3 @@ CollectionTypes = Set.new([
|
|
87
90
|
%q"array",
|
88
91
|
%q"map",
|
89
92
|
])
|
90
|
-
|