7
7
import com .skey .evehbase .util .GenericUtils ;
8
8
import com .skey .evehbase .util .HResultUtils ;
9
9
import com .skey .evehbase .util .IOUtils ;
10
+ import com .skey .evehbase .util .PutBuffer ;
10
11
import org .apache .hadoop .conf .Configuration ;
11
12
import org .apache .hadoop .hbase .*;
12
13
import org .apache .hadoop .hbase .client .*;
@@ -111,15 +112,33 @@ public void create(@Nonnull EveTable eveTable) {
111
112
if (LOG .isErrorEnabled ()) LOG .error ("Create table failed." , e );
112
113
} finally {
113
114
close (admin , "Close admin failed " );
115
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting create." );
114
116
}
115
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting create." );
116
117
}
117
118
118
119
@ Override
119
- public void disable (EveTable eveTable ) {
120
+ public Table getTable (String tableName ) {
121
+ if (LOG .isInfoEnabled ()) LOG .info ("Entering getTable." );
122
+
123
+ Table table = null ;
124
+ try {
125
+ table = conn .getTable (TableName .valueOf (tableName ));
126
+
127
+ if (LOG .isInfoEnabled ()) LOG .info ("GetTable successfully." );
128
+ } catch (IOException e ) {
129
+ if (LOG .isErrorEnabled ()) LOG .error ("Get table failed." , e );
130
+ } finally {
131
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting getTable." );
132
+ }
133
+
134
+ return table ;
135
+ }
136
+
137
+ @ Override
138
+ public void disable (String tableName ) {
120
139
if (LOG .isInfoEnabled ()) LOG .info ("Entering disable." );
121
140
122
- TableName tn = eveTable . getTableName ( );
141
+ TableName tn = TableName . valueOf ( tableName );
123
142
124
143
Admin admin = null ;
125
144
try {
@@ -141,15 +160,15 @@ public void disable(EveTable eveTable) {
141
160
if (LOG .isErrorEnabled ()) LOG .error ("Disable table failed." , e );
142
161
} finally {
143
162
close (admin , "Close admin failed " );
163
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting disable." );
144
164
}
145
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting disable." );
146
165
}
147
166
148
167
@ Override
149
- public void enable (EveTable eveTable ) {
168
+ public void enable (String tableName ) {
150
169
if (LOG .isInfoEnabled ()) LOG .info ("Entering enable." );
151
170
152
- TableName tn = eveTable . getTableName ( );
171
+ TableName tn = TableName . valueOf ( tableName );
153
172
154
173
Admin admin = null ;
155
174
try {
@@ -171,15 +190,15 @@ public void enable(EveTable eveTable) {
171
190
if (LOG .isErrorEnabled ()) LOG .error ("Enable table failed." , e );
172
191
} finally {
173
192
close (admin , "Close admin failed " );
193
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting enable." );
174
194
}
175
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting enable." );
176
195
}
177
196
178
197
@ Override
179
- public void delete (EveTable eveTable ) {
198
+ public void delete (String tableName ) {
180
199
if (LOG .isInfoEnabled ()) LOG .info ("Entering delete." );
181
200
182
- TableName tn = eveTable . getTableName ( );
201
+ TableName tn = TableName . valueOf ( tableName );
183
202
184
203
Admin admin = null ;
185
204
try {
@@ -201,15 +220,15 @@ public void delete(EveTable eveTable) {
201
220
if (LOG .isErrorEnabled ()) LOG .error ("Delete table failed." , e );
202
221
} finally {
203
222
close (admin , "Close admin failed " );
223
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting delete." );
204
224
}
205
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting delete." );
206
225
}
207
226
208
227
@ Override
209
- public void disableAndDelete (EveTable eveTable ) {
228
+ public void disableAndDelete (String tableName ) {
210
229
if (LOG .isInfoEnabled ()) LOG .info ("Entering DisableAndDelete." );
211
230
212
- TableName tn = eveTable . getTableName ( );
231
+ TableName tn = TableName . valueOf ( tableName );
213
232
214
233
Admin admin = null ;
215
234
try {
@@ -232,8 +251,8 @@ public void disableAndDelete(EveTable eveTable) {
232
251
if (LOG .isErrorEnabled ()) LOG .error ("DisableAndDelete table failed." , e );
233
252
} finally {
234
253
close (admin , "Close admin failed " );
254
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting DisableAndDelete." );
235
255
}
236
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting DisableAndDelete." );
237
256
}
238
257
239
258
@ Override
@@ -269,8 +288,8 @@ public void multiSplit(@Nonnull String tableName, @Nonnull String... splitKeys)
269
288
} finally {
270
289
close (table , "Close table failed " );
271
290
close (admin , "Close admin failed " );
291
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting multiSplit." );
272
292
}
273
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting multiSplit." );
274
293
}
275
294
276
295
@ Override
@@ -313,8 +332,14 @@ public void createIndex(@Nonnull String tableName, @Nonnull String familyName,
313
332
} finally {
314
333
close (admin , "Close admin failed " );
315
334
close (iAdmin , "Close admin failed " );
335
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting createIndex." );
316
336
}
317
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting createIndex." );
337
+ }
338
+
339
+ @ Override
340
+ public PutBuffer createPutBuffer (String tableName , int bufferSize , int duration ) {
341
+ Table table = getTable (tableName );
342
+ return new PutBuffer (table , bufferSize , duration );
318
343
}
319
344
320
345
@ Override
@@ -347,8 +372,8 @@ public void put(@Nonnull String tableName, @Nonnull List<Put> putList) throws IO
347
372
if (LOG .isInfoEnabled ()) LOG .info ("Put successfully." );
348
373
} finally {
349
374
close (table , "Close table failed " );
375
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting Put." );
350
376
}
351
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting put." );
352
377
}
353
378
354
379
@ Override
@@ -365,7 +390,7 @@ public <T> List<T> scan(@Nonnull EveScan eveScan, @Nonnull Class<T> clazz) throw
365
390
// 提交scan请求
366
391
scanner = table .getScanner (eveScan .getScan ());
367
392
Result r ;
368
- while ((r = scanner .next ()) != null ) {
393
+ while ((r = scanner .next ()) != null ) {
369
394
results .add (r );
370
395
}
371
396
@@ -416,7 +441,7 @@ public <T> List<T> get(@Nonnull EveGet eveGet, @Nonnull Class<T> clazz) throws I
416
441
417
442
List <T > objects = HResultUtils .parseResults (results , clazz );
418
443
419
- if (LOG .isInfoEnabled ()) LOG .info ("Exiting testGet ." );
444
+ if (LOG .isInfoEnabled ()) LOG .info ("Exiting Get ." );
420
445
return objects ;
421
446
}
422
447
0 commit comments