-
Notifications
You must be signed in to change notification settings - Fork 178
/
AbstractBigtableTable.java
743 lines (673 loc) · 25.1 KB
/
AbstractBigtableTable.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
/*
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.bigtable.hbase;
import com.google.api.core.InternalApi;
import com.google.cloud.bigtable.config.BigtableOptions;
import com.google.cloud.bigtable.config.Logger;
import com.google.cloud.bigtable.core.IBigtableDataClient;
import com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation;
import com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow;
import com.google.cloud.bigtable.data.v2.models.RowMutation;
import com.google.cloud.bigtable.grpc.BigtableSession;
import com.google.cloud.bigtable.grpc.scanner.FlatRow;
import com.google.cloud.bigtable.hbase.adapters.Adapters;
import com.google.cloud.bigtable.hbase.adapters.CheckAndMutateUtil;
import com.google.cloud.bigtable.hbase.adapters.HBaseRequestAdapter;
import com.google.cloud.bigtable.hbase.adapters.read.GetAdapter;
import com.google.cloud.bigtable.metrics.BigtableClientMetrics;
import com.google.cloud.bigtable.metrics.BigtableClientMetrics.MetricLevel;
import com.google.cloud.bigtable.metrics.Timer;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import io.opencensus.common.Scope;
import io.opencensus.trace.AttributeValue;
import io.opencensus.trace.Span;
import io.opencensus.trace.Status;
import io.opencensus.trace.Tracer;
import io.opencensus.trace.Tracing;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.AbstractBigtableConnection;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.client.Row;
import org.apache.hadoop.hbase.client.RowMutations;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.WhileMatchFilter;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.Message;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.Service;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.util.Bytes;
/**
* BigtableTable class. Scan methods return rows in key order.
*
* <p>For internal use only - public for technical reasons.
*/
@InternalApi("For internal usage only")
@SuppressWarnings("deprecation")
public abstract class AbstractBigtableTable implements Table {
/** Constant <code>LOG</code> */
protected static final Logger LOG = new Logger(AbstractBigtableTable.class);
private static final Tracer TRACER = Tracing.getTracer();
private static class TableMetrics {
Timer putTimer = BigtableClientMetrics.timer(MetricLevel.Info, "table.put.latency");
Timer getTimer = BigtableClientMetrics.timer(MetricLevel.Info, "table.get.latency");
}
private static void addBatchSizeAnnotation(Collection<?> c) {
TRACER
.getCurrentSpan()
.addAnnotation(
"batchSize", ImmutableMap.of("size", AttributeValue.longAttributeValue(c.size())));
}
protected final TableName tableName;
protected final BigtableOptions options;
protected final HBaseRequestAdapter hbaseAdapter;
protected final IBigtableDataClient clientWrapper;
private BatchExecutor batchExecutor;
protected final AbstractBigtableConnection bigtableConnection;
private TableMetrics metrics = new TableMetrics();
/**
* Constructed by BigtableConnection
*
* @param bigtableConnection a {@link AbstractBigtableConnection} object.
* @param hbaseAdapter a {@link HBaseRequestAdapter} object.
*/
public AbstractBigtableTable(
AbstractBigtableConnection bigtableConnection, HBaseRequestAdapter hbaseAdapter) {
this.bigtableConnection = bigtableConnection;
BigtableSession session = bigtableConnection.getSession();
this.options = session.getOptions();
this.clientWrapper = session.getDataClientWrapper();
this.hbaseAdapter = hbaseAdapter;
this.tableName = hbaseAdapter.getTableName();
}
/** {@inheritDoc} */
@Override
public TableName getName() {
return this.tableName;
}
/** {@inheritDoc} */
@Override
public final Configuration getConfiguration() {
return this.bigtableConnection.getConfiguration();
}
/** {@inheritDoc} */
@Override
public HTableDescriptor getTableDescriptor() throws IOException {
try (Scope scope = TRACER.spanBuilder("BigtableTable.getTableDescriptor").startScopedSpan();
Admin admin = this.bigtableConnection.getAdmin()) {
return admin.getTableDescriptor(tableName);
}
}
/** {@inheritDoc} */
@Override
public boolean exists(Get get) throws IOException {
try (Scope scope = TRACER.spanBuilder("BigtableTable.exists").startScopedSpan()) {
LOG.trace("exists(Get)");
return !convertToResult(getResults(GetAdapter.setCheckExistenceOnly(get), "exists"))
.isEmpty();
}
}
/** {@inheritDoc} */
@Override
public boolean[] existsAll(List<Get> gets) throws IOException {
LOG.trace("existsAll(Get)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.existsAll").startScopedSpan()) {
addBatchSizeAnnotation(gets);
List<Get> existGets = new ArrayList<>(gets.size());
for (Get get : gets) {
existGets.add(GetAdapter.setCheckExistenceOnly(get));
}
return getBatchExecutor().exists(existGets);
}
}
/** {@inheritDoc} */
@Override
public void batch(List<? extends Row> actions, Object[] results)
throws IOException, InterruptedException {
LOG.trace("batch(List<>, Object[])");
try (Scope scope = TRACER.spanBuilder("BigtableTable.batch").startScopedSpan()) {
addBatchSizeAnnotation(actions);
getBatchExecutor().batch(actions, results);
}
}
/** {@inheritDoc} */
@Deprecated
@Override
public Object[] batch(List<? extends Row> actions) throws IOException, InterruptedException {
LOG.trace("batch(List<>)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.batch").startScopedSpan()) {
addBatchSizeAnnotation(actions);
return getBatchExecutor().batch(actions);
}
}
/** {@inheritDoc} */
@Override
public <R> void batchCallback(
List<? extends Row> actions, Object[] results, Batch.Callback<R> callback)
throws IOException, InterruptedException {
LOG.trace("batchCallback(List<>, Object[], Batch.Callback)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.batchCallback").startScopedSpan()) {
addBatchSizeAnnotation(actions);
getBatchExecutor().batchCallback(actions, results, callback);
}
}
/** {@inheritDoc} */
@Deprecated
@Override
public <R> Object[] batchCallback(List<? extends Row> actions, Batch.Callback<R> callback)
throws IOException, InterruptedException {
LOG.trace("batchCallback(List<>, Batch.Callback)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.batchCallback").startScopedSpan()) {
addBatchSizeAnnotation(actions);
Object[] results = new Object[actions.size()];
getBatchExecutor().batchCallback(actions, results, callback);
return results;
}
}
/** {@inheritDoc} */
@Override
public Result[] get(List<Get> gets) throws IOException {
LOG.trace("get(List<>)");
Preconditions.checkNotNull(gets);
if (gets.isEmpty()) {
return new Result[0];
} else if (gets.size() == 1) {
try {
return new Result[] {get(gets.get(0))};
} catch (IOException e) {
throw createRetriesExhaustedWithDetailsException(e, gets.get(0));
}
} else {
try (Scope scope = TRACER.spanBuilder("BigtableTable.get").startScopedSpan()) {
addBatchSizeAnnotation(gets);
return getBatchExecutor().batch(gets);
}
}
}
private RetriesExhaustedWithDetailsException createRetriesExhaustedWithDetailsException(
Throwable e, Row action) {
return new RetriesExhaustedWithDetailsException(
Arrays.asList(e), Arrays.asList(action), Arrays.asList(options.getDataHost().toString()));
}
/** {@inheritDoc} */
@Override
public Result get(Get get) throws IOException {
LOG.trace("get(Get)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.get").startScopedSpan()) {
return convertToResult(getResults(get, "get"));
}
}
private FlatRow getResults(Get get, String method) {
try (Timer.Context ignored = metrics.getTimer.time()) {
List<FlatRow> list = clientWrapper.readFlatRowsList(hbaseAdapter.adapt(get));
switch (list.size()) {
case 0:
return null;
case 1:
return list.get(0);
default:
throw new IllegalStateException("Multiple responses found for " + method);
}
}
}
protected Result convertToResult(FlatRow row) {
if (row == null) {
return Adapters.FLAT_ROW_ADAPTER.adaptResponse(null);
} else {
return Adapters.FLAT_ROW_ADAPTER.adaptResponse(row);
}
}
/** {@inheritDoc} */
@Override
public ResultScanner getScanner(Scan scan) throws IOException {
LOG.trace("getScanner(Scan)");
Span span = TRACER.spanBuilder("BigtableTable.scan").startSpan();
try (Scope scope = TRACER.withSpan(span)) {
com.google.cloud.bigtable.grpc.scanner.ResultScanner<FlatRow> scanner =
clientWrapper.readFlatRows(hbaseAdapter.adapt(scan));
if (hasWhileMatchFilter(scan.getFilter())) {
return Adapters.BIGTABLE_WHILE_MATCH_RESULT_RESULT_SCAN_ADAPTER.adapt(scanner, span);
}
return Adapters.BIGTABLE_RESULT_SCAN_ADAPTER.adapt(scanner, span);
} catch (Throwable throwable) {
LOG.error("Encountered exception when executing getScanner.", throwable);
span.setStatus(Status.UNKNOWN);
// Close the span only when throw an exception and not on finally because if no exception
// the span will be ended by the adapter.
span.end();
throw new IOException(
makeGenericExceptionMessage(
"getScanner", options.getProjectId(), tableName.getQualifierAsString()),
throwable);
}
}
public static boolean hasWhileMatchFilter(Filter filter) {
if (filter instanceof WhileMatchFilter) {
return true;
}
if (filter instanceof FilterList) {
FilterList list = (FilterList) filter;
for (Filter subFilter : list.getFilters()) {
if (hasWhileMatchFilter(subFilter)) {
return true;
}
}
}
return false;
}
/** {@inheritDoc} */
@Override
public ResultScanner getScanner(byte[] family) throws IOException {
LOG.trace("getScanner(byte[])");
return getScanner(new Scan().addFamily(family));
}
/** {@inheritDoc} */
@Override
public ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException {
LOG.trace("getScanner(byte[], byte[])");
return getScanner(new Scan().addColumn(family, qualifier));
}
/** {@inheritDoc} */
@Override
public void put(Put put) throws IOException {
LOG.trace("put(Put)");
RowMutation rowMutation = hbaseAdapter.adapt(put);
mutateRow(put, rowMutation, "put");
}
/** {@inheritDoc} */
@Override
public void put(List<Put> puts) throws IOException {
LOG.trace("put(List<Put>)");
Preconditions.checkNotNull(puts);
if (puts.isEmpty()) {
return;
} else if (puts.size() == 1) {
try {
put(puts.get(0));
} catch (IOException e) {
throw createRetriesExhaustedWithDetailsException(e, puts.get(0));
}
} else {
getBatchExecutor().batch(puts);
}
}
/** {@inheritDoc} */
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
throws IOException {
return checkAndPut(row, family, qualifier, CompareFilter.CompareOp.EQUAL, value, put);
}
/** {@inheritDoc} */
@Override
public boolean checkAndPut(
byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
Put put)
throws IOException {
LOG.trace("checkAndPut(byte[], byte[], byte[], CompareOp, value, Put)");
ConditionalRowMutation request =
new CheckAndMutateUtil.RequestBuilder(hbaseAdapter, row, family)
.qualifier(qualifier)
.ifMatches(compareOp, value)
.withPut(put)
.build();
return checkAndMutate(row, request, "checkAndPut");
}
/** {@inheritDoc} */
@Override
public void delete(Delete delete) throws IOException {
LOG.trace("delete(Delete)");
RowMutation rowMutation = hbaseAdapter.adapt(delete);
mutateRow(delete, rowMutation, "delete");
}
/** {@inheritDoc} */
@Override
public void delete(List<Delete> deletes) throws IOException {
LOG.trace("delete(List<Delete>)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.delete").startScopedSpan()) {
getBatchExecutor().batch(deletes);
}
}
/** {@inheritDoc} */
@Override
public boolean checkAndDelete(
byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete) throws IOException {
return checkAndDelete(row, family, qualifier, CompareFilter.CompareOp.EQUAL, value, delete);
}
/** {@inheritDoc} */
@Override
public boolean checkAndDelete(
byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
Delete delete)
throws IOException {
LOG.trace("checkAndDelete(byte[], byte[], byte[], CompareOp, byte[], Delete)");
ConditionalRowMutation request =
new CheckAndMutateUtil.RequestBuilder(hbaseAdapter, row, family)
.qualifier(qualifier)
.ifMatches(compareOp, value)
.withDelete(delete)
.build();
return checkAndMutate(row, request, "checkAndDelete");
}
/** {@inheritDoc} */
@Override
public boolean checkAndMutate(
final byte[] row,
final byte[] family,
final byte[] qualifier,
final CompareFilter.CompareOp compareOp,
final byte[] value,
final RowMutations rm)
throws IOException {
LOG.trace("checkAndMutate(byte[], byte[], byte[], CompareOp, byte[], RowMutations)");
ConditionalRowMutation request =
new CheckAndMutateUtil.RequestBuilder(hbaseAdapter, row, family)
.qualifier(qualifier)
.ifMatches(compareOp, value)
.withMutations(rm)
.build();
return checkAndMutate(row, request, "checkAndMutate");
}
private boolean checkAndMutate(final byte[] row, ConditionalRowMutation request, String type)
throws IOException {
Span span = TRACER.spanBuilder("BigtableTable." + type).startSpan();
try (Scope scope = TRACER.withSpan(span)) {
Boolean wasApplied = clientWrapper.checkAndMutateRow(request);
return CheckAndMutateUtil.wasMutationApplied(request, wasApplied);
} catch (Throwable t) {
span.setStatus(Status.UNKNOWN);
throw logAndCreateIOException(type, row, t);
} finally {
span.end();
}
}
private void mutateRow(Mutation mutation, RowMutation rowMutation, String type)
throws IOException {
Span span = TRACER.spanBuilder("BigtableTable." + type).startSpan();
try (Scope scope = TRACER.withSpan(span)) {
clientWrapper.mutateRow(rowMutation);
} catch (Throwable t) {
span.setStatus(Status.UNKNOWN);
throw logAndCreateIOException(type, mutation.getRow(), t);
} finally {
span.end();
}
}
/** {@inheritDoc} */
@Override
public void mutateRow(RowMutations rowMutations) throws IOException {
LOG.trace("mutateRow(RowMutation)");
if (rowMutations.getMutations().isEmpty()) {
return;
}
Span span = TRACER.spanBuilder("BigtableTable.mutateRow").startSpan();
try (Scope scope = TRACER.withSpan(span)) {
clientWrapper.mutateRow(hbaseAdapter.adapt(rowMutations));
} catch (Throwable t) {
span.setStatus(Status.UNKNOWN);
throw logAndCreateIOException("mutateRow", rowMutations.getRow(), t);
} finally {
span.end();
}
}
/** {@inheritDoc} */
@Override
public Result append(Append append) throws IOException {
LOG.trace("append(Append)");
Span span = TRACER.spanBuilder("BigtableTable.append").startSpan();
try (Scope scope = TRACER.withSpan(span)) {
com.google.cloud.bigtable.data.v2.models.Row response =
clientWrapper.readModifyWriteRow(hbaseAdapter.adapt(append));
// The bigtable API will always return the mutated results. In order to maintain
// compatibility, simply return null when results were not requested.
if (append.isReturnResults()) {
return Adapters.ROW_ADAPTER.adaptResponse(response);
} else {
return null;
}
} catch (Throwable t) {
span.setStatus(Status.UNKNOWN);
throw logAndCreateIOException("append", append.getRow(), t);
} finally {
span.end();
}
}
/** {@inheritDoc} */
@Override
public Result increment(Increment increment) throws IOException {
LOG.trace("increment(Increment)");
Span span = TRACER.spanBuilder("BigtableTable.increment").startSpan();
try (Scope scope = TRACER.withSpan(span)) {
ReadModifyWriteRow request = hbaseAdapter.adapt(increment);
return Adapters.ROW_ADAPTER.adaptResponse(clientWrapper.readModifyWriteRow(request));
} catch (Throwable t) {
span.setStatus(Status.UNKNOWN);
throw logAndCreateIOException("increment", increment.getRow(), t);
} finally {
span.end();
}
}
private IOException logAndCreateIOException(String type, byte[] row, Throwable t) {
LOG.error("Encountered exception when executing " + type + ".", t);
return new DoNotRetryIOException(
makeGenericExceptionMessage(
type, options.getProjectId(), tableName.getQualifierAsString(), row),
t);
}
/** {@inheritDoc} */
@Override
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount)
throws IOException {
LOG.trace("incrementColumnValue(byte[], byte[], byte[], long)");
try (Scope scope = TRACER.spanBuilder("BigtableTable.incrementColumnValue").startScopedSpan()) {
Increment incr = new Increment(row);
incr.addColumn(family, qualifier, amount);
Result result = increment(incr);
Cell cell = result.getColumnLatestCell(family, qualifier);
if (cell == null) {
LOG.error("Failed to find a incremented value in result of increment");
throw new IOException(
makeGenericExceptionMessage(
"increment", options.getProjectId(), tableName.getQualifierAsString(), row));
}
return Bytes.toLong(CellUtil.cloneValue(cell));
}
}
/** {@inheritDoc} */
@Override
public long incrementColumnValue(
byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability)
throws IOException {
LOG.trace("incrementColumnValue(byte[], byte[], byte[], long, Durability)");
return incrementColumnValue(row, family, qualifier, amount);
}
/** {@inheritDoc} */
@Override
public void close() throws IOException {
// TODO: shutdown the executor.
}
/** {@inheritDoc} */
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
LOG.error("Unsupported coprocessorService(byte[]) called.");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Override
public <T extends Service, R> Map<byte[], R> coprocessorService(
Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T, R> callable)
throws ServiceException, Throwable {
LOG.error("Unsupported coprocessorService(Class, byte[], byte[], Batch.Call) called.");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Override
public <T extends Service, R> void coprocessorService(
Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T, R> callable,
Batch.Callback<R> callback)
throws ServiceException, Throwable {
LOG.error(
"Unsupported coprocessorService("
+ "Class, byte[], byte[], Batch.Call, Batch.Callback) called.");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Deprecated
@Override
public long getWriteBufferSize() {
LOG.error("Unsupported getWriteBufferSize() called");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Deprecated
@Override
public void setWriteBufferSize(long writeBufferSize) throws IOException {
LOG.error("Unsupported getWriteBufferSize() called");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Override
public <R extends Message> Map<byte[], R> batchCoprocessorService(
Descriptors.MethodDescriptor methodDescriptor,
Message message,
byte[] bytes,
byte[] bytes2,
R r)
throws ServiceException, Throwable {
LOG.error(
"Unsupported batchCoprocessorService("
+ "MethodDescriptor, Message, byte[], byte[], R) called.");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Override
public <R extends Message> void batchCoprocessorService(
Descriptors.MethodDescriptor methodDescriptor,
Message message,
byte[] bytes,
byte[] bytes2,
R r,
Batch.Callback<R> rCallback)
throws ServiceException, Throwable {
LOG.error(
"Unsupported batchCoprocessorService("
+ "MethodDescriptor, Message, byte[], byte[], R, Batch.Callback<R>) called.");
throw new UnsupportedOperationException(); // TODO
}
/** {@inheritDoc} */
@Override
public String toString() {
return MoreObjects.toStringHelper(AbstractBigtableTable.class)
.add("hashCode", "0x" + Integer.toHexString(hashCode()))
.add("project", options.getProjectId())
.add("instance", options.getInstanceId())
.add("table", tableName.getNameAsString())
.add("host", options.getDataHost())
.toString();
}
static String makeGenericExceptionMessage(String operation, String projectId, String tableName) {
return String.format(
"Failed to perform operation. Operation='%s', projectId='%s', tableName='%s'",
operation, projectId, tableName);
}
static String makeGenericExceptionMessage(
String operation, String projectId, String tableName, byte[] rowKey) {
return String.format(
"Failed to perform operation. Operation='%s', projectId='%s', tableName='%s', rowKey='%s'",
operation, projectId, tableName, Bytes.toStringBinary(rowKey));
}
/**
* Getter for the field <code>batchExecutor</code>.
*
* @return a {@link com.google.cloud.bigtable.hbase.BatchExecutor} object.
*/
protected synchronized BatchExecutor getBatchExecutor() {
if (batchExecutor == null) {
batchExecutor = new BatchExecutor(bigtableConnection.getSession(), hbaseAdapter);
}
return batchExecutor;
}
@Override
public void setOperationTimeout(int i) {
throw new UnsupportedOperationException("setOperationTimeout");
}
@Override
public int getOperationTimeout() {
throw new UnsupportedOperationException("getOperationTimeout");
}
@Override
public void setRpcTimeout(int i) {
throw new UnsupportedOperationException("setRpcTimeout");
}
@Override
public int getReadRpcTimeout() {
throw new UnsupportedOperationException("getReadRpcTimeout");
}
@Override
public void setReadRpcTimeout(int i) {
throw new UnsupportedOperationException("setReadRpcTimeout");
}
@Override
public int getWriteRpcTimeout() {
throw new UnsupportedOperationException("getWriteRpcTimeout");
}
@Override
public void setWriteRpcTimeout(int i) {
throw new UnsupportedOperationException("setWriteRpcTimeout");
}
@Override
public int getRpcTimeout() {
throw new UnsupportedOperationException("getRpcTimeout");
}
}