1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.coprocessor;
21
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.NavigableSet;
26
27 import org.apache.hadoop.hbase.classification.InterfaceAudience;
28 import org.apache.hadoop.hbase.classification.InterfaceStability;
29 import org.apache.hadoop.fs.FileSystem;
30 import org.apache.hadoop.fs.Path;
31 import org.apache.hadoop.hbase.Cell;
32 import org.apache.hadoop.hbase.CoprocessorEnvironment;
33 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
34 import org.apache.hadoop.hbase.HRegionInfo;
35 import org.apache.hadoop.hbase.client.Append;
36 import org.apache.hadoop.hbase.client.Delete;
37 import org.apache.hadoop.hbase.client.Durability;
38 import org.apache.hadoop.hbase.client.Get;
39 import org.apache.hadoop.hbase.client.Increment;
40 import org.apache.hadoop.hbase.client.Mutation;
41 import org.apache.hadoop.hbase.client.Put;
42 import org.apache.hadoop.hbase.client.Result;
43 import org.apache.hadoop.hbase.client.Scan;
44 import org.apache.hadoop.hbase.filter.ByteArrayComparable;
45 import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
46 import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper;
47 import org.apache.hadoop.hbase.io.Reference;
48 import org.apache.hadoop.hbase.io.hfile.CacheConfig;
49 import org.apache.hadoop.hbase.regionserver.DeleteTracker;
50 import org.apache.hadoop.hbase.regionserver.InternalScanner;
51 import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
52 import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
53 import org.apache.hadoop.hbase.regionserver.Region;
54 import org.apache.hadoop.hbase.regionserver.Region.Operation;
55 import org.apache.hadoop.hbase.regionserver.RegionScanner;
56 import org.apache.hadoop.hbase.regionserver.ScanType;
57 import org.apache.hadoop.hbase.regionserver.Store;
58 import org.apache.hadoop.hbase.regionserver.StoreFile;
59 import org.apache.hadoop.hbase.regionserver.StoreFile.Reader;
60 import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
61 import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
62 import org.apache.hadoop.hbase.wal.WALKey;
63 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
64 import org.apache.hadoop.hbase.util.Pair;
65
66 import com.google.common.collect.ImmutableList;
67
68
69
70
71
72
73 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
74 @InterfaceStability.Evolving
75 public abstract class BaseRegionObserver implements RegionObserver {
76 @Override
77 public void start(CoprocessorEnvironment e) throws IOException { }
78
79 @Override
80 public void stop(CoprocessorEnvironment e) throws IOException { }
81
82 @Override
83 public void preOpen(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException { }
84
85 @Override
86 public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) { }
87
88 @Override
89 public void postLogReplay(ObserverContext<RegionCoprocessorEnvironment> e) { }
90
91 @Override
92 public void preClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested)
93 throws IOException { }
94
95 @Override
96 public void postClose(ObserverContext<RegionCoprocessorEnvironment> e,
97 boolean abortRequested) { }
98
99 @Override
100 public InternalScanner preFlushScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
101 final Store store, final KeyValueScanner memstoreScanner, final InternalScanner s)
102 throws IOException {
103 return s;
104 }
105
106 @Override
107 public void preFlush(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException {
108 }
109
110 @Override
111 public void postFlush(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException {
112 }
113
114 @Override
115 public InternalScanner preFlush(ObserverContext<RegionCoprocessorEnvironment> e, Store store,
116 InternalScanner scanner) throws IOException {
117 return scanner;
118 }
119
120 @Override
121 public void postFlush(ObserverContext<RegionCoprocessorEnvironment> e, Store store,
122 StoreFile resultFile) throws IOException {
123 }
124
125 @Override
126 public void preSplit(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException {
127 }
128
129 @Override
130 public void preSplit(ObserverContext<RegionCoprocessorEnvironment> c,
131 byte[] splitRow) throws IOException {
132 }
133
134 @Override
135 public void preSplitBeforePONR(ObserverContext<RegionCoprocessorEnvironment> ctx,
136 byte[] splitKey, List<Mutation> metaEntries) throws IOException {
137 }
138
139 @Override
140 public void preSplitAfterPONR(
141 ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException {
142 }
143
144 @Override
145 public void preRollBackSplit(ObserverContext<RegionCoprocessorEnvironment> ctx)
146 throws IOException {
147 }
148
149 @Override
150 public void postRollBackSplit(
151 ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException {
152 }
153
154 @Override
155 public void postCompleteSplit(
156 ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException {
157 }
158
159 @Override
160 public void postSplit(ObserverContext<RegionCoprocessorEnvironment> e, Region l, Region r)
161 throws IOException {
162 }
163
164 @Override
165 public void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
166 final Store store, final List<StoreFile> candidates) throws IOException { }
167
168 @Override
169 public void preCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
170 final Store store, final List<StoreFile> candidates, final CompactionRequest request)
171 throws IOException {
172 preCompactSelection(c, store, candidates);
173 }
174
175 @Override
176 public void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
177 final Store store, final ImmutableList<StoreFile> selected) { }
178
179 @Override
180 public void postCompactSelection(final ObserverContext<RegionCoprocessorEnvironment> c,
181 final Store store, final ImmutableList<StoreFile> selected, CompactionRequest request) {
182 postCompactSelection(c, store, selected);
183 }
184
185 @Override
186 public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> e,
187 final Store store, final InternalScanner scanner, final ScanType scanType)
188 throws IOException {
189 return scanner;
190 }
191
192 @Override
193 public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> e,
194 final Store store, final InternalScanner scanner, final ScanType scanType,
195 CompactionRequest request) throws IOException {
196 return preCompact(e, store, scanner, scanType);
197 }
198
199 @Override
200 public InternalScanner preCompactScannerOpen(
201 final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
202 List<? extends KeyValueScanner> scanners, final ScanType scanType, final long earliestPutTs,
203 final InternalScanner s) throws IOException {
204 return s;
205 }
206
207 @Override
208 public InternalScanner preCompactScannerOpen(
209 final ObserverContext<RegionCoprocessorEnvironment> c, final Store store,
210 List<? extends KeyValueScanner> scanners, final ScanType scanType, final long earliestPutTs,
211 final InternalScanner s, CompactionRequest request) throws IOException {
212 return preCompactScannerOpen(c, store, scanners, scanType, earliestPutTs, s);
213 }
214
215 @Override
216 public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e, final Store store,
217 final StoreFile resultFile) throws IOException {
218 }
219
220 @Override
221 public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e, final Store store,
222 final StoreFile resultFile, CompactionRequest request) throws IOException {
223 postCompact(e, store, resultFile);
224 }
225
226 @Override
227 public void preGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment> e,
228 final byte [] row, final byte [] family, final Result result)
229 throws IOException {
230 }
231
232 @Override
233 public void postGetClosestRowBefore(final ObserverContext<RegionCoprocessorEnvironment> e,
234 final byte [] row, final byte [] family, final Result result)
235 throws IOException {
236 }
237
238 @Override
239 public void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> e,
240 final Get get, final List<Cell> results) throws IOException {
241 }
242
243 @Override
244 public void postGetOp(final ObserverContext<RegionCoprocessorEnvironment> e,
245 final Get get, final List<Cell> results) throws IOException {
246 }
247
248 @Override
249 public boolean preExists(final ObserverContext<RegionCoprocessorEnvironment> e,
250 final Get get, final boolean exists) throws IOException {
251 return exists;
252 }
253
254 @Override
255 public boolean postExists(final ObserverContext<RegionCoprocessorEnvironment> e,
256 final Get get, boolean exists) throws IOException {
257 return exists;
258 }
259
260 @Override
261 public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e,
262 final Put put, final WALEdit edit, final Durability durability) throws IOException {
263 }
264
265 @Override
266 public void postPut(final ObserverContext<RegionCoprocessorEnvironment> e,
267 final Put put, final WALEdit edit, final Durability durability) throws IOException {
268 }
269
270 @Override
271 public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> e, final Delete delete,
272 final WALEdit edit, final Durability durability) throws IOException {
273 }
274
275 @Override
276 public void prePrepareTimeStampForDeleteVersion(
277 final ObserverContext<RegionCoprocessorEnvironment> e, final Mutation delete,
278 final Cell cell, final byte[] byteNow, final Get get) throws IOException {
279 }
280
281 @Override
282 public void postDelete(final ObserverContext<RegionCoprocessorEnvironment> e,
283 final Delete delete, final WALEdit edit, final Durability durability)
284 throws IOException {
285 }
286
287 @Override
288 public void preBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
289 final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
290 }
291
292 @Override
293 public void postBatchMutate(final ObserverContext<RegionCoprocessorEnvironment> c,
294 final MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
295 }
296
297 @Override
298 public void postBatchMutateIndispensably(final ObserverContext<RegionCoprocessorEnvironment> ctx,
299 MiniBatchOperationInProgress<Mutation> miniBatchOp, final boolean success) throws IOException {
300 }
301
302 @Override
303 public boolean preCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> e,
304 final byte [] row, final byte [] family, final byte [] qualifier,
305 final CompareOp compareOp, final ByteArrayComparable comparator,
306 final Put put, final boolean result) throws IOException {
307 return result;
308 }
309
310 @Override
311 public boolean preCheckAndPutAfterRowLock(
312 final ObserverContext<RegionCoprocessorEnvironment> e,
313 final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp,
314 final ByteArrayComparable comparator, final Put put,
315 final boolean result) throws IOException {
316 return result;
317 }
318
319 @Override
320 public boolean postCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> e,
321 final byte [] row, final byte [] family, final byte [] qualifier,
322 final CompareOp compareOp, final ByteArrayComparable comparator,
323 final Put put, final boolean result) throws IOException {
324 return result;
325 }
326
327 @Override
328 public boolean preCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> e,
329 final byte [] row, final byte [] family, final byte [] qualifier,
330 final CompareOp compareOp, final ByteArrayComparable comparator,
331 final Delete delete, final boolean result) throws IOException {
332 return result;
333 }
334
335 @Override
336 public boolean preCheckAndDeleteAfterRowLock(
337 final ObserverContext<RegionCoprocessorEnvironment> e,
338 final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp,
339 final ByteArrayComparable comparator, final Delete delete,
340 final boolean result) throws IOException {
341 return result;
342 }
343
344 @Override
345 public boolean postCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> e,
346 final byte [] row, final byte [] family, final byte [] qualifier,
347 final CompareOp compareOp, final ByteArrayComparable comparator,
348 final Delete delete, final boolean result) throws IOException {
349 return result;
350 }
351
352 @Override
353 public Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> e,
354 final Append append) throws IOException {
355 return null;
356 }
357
358 @Override
359 public Result preAppendAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> e,
360 final Append append) throws IOException {
361 return null;
362 }
363
364 @Override
365 public Result postAppend(final ObserverContext<RegionCoprocessorEnvironment> e,
366 final Append append, final Result result) throws IOException {
367 return result;
368 }
369
370 @Override
371 public long preIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> e,
372 final byte [] row, final byte [] family, final byte [] qualifier,
373 final long amount, final boolean writeToWAL) throws IOException {
374 return amount;
375 }
376
377 @Override
378 public long postIncrementColumnValue(final ObserverContext<RegionCoprocessorEnvironment> e,
379 final byte [] row, final byte [] family, final byte [] qualifier,
380 final long amount, final boolean writeToWAL, long result)
381 throws IOException {
382 return result;
383 }
384
385 @Override
386 public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> e,
387 final Increment increment) throws IOException {
388 return null;
389 }
390
391 @Override
392 public Result preIncrementAfterRowLock(final ObserverContext<RegionCoprocessorEnvironment> e,
393 final Increment increment) throws IOException {
394 return null;
395 }
396
397 @Override
398 public Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> e,
399 final Increment increment, final Result result) throws IOException {
400 return result;
401 }
402
403 @Override
404 public RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> e,
405 final Scan scan, final RegionScanner s) throws IOException {
406 return s;
407 }
408
409 @Override
410 public KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
411 final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
412 final KeyValueScanner s) throws IOException {
413 return s;
414 }
415
416 @Override
417 public RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> e,
418 final Scan scan, final RegionScanner s) throws IOException {
419 return s;
420 }
421
422 @Override
423 public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> e,
424 final InternalScanner s, final List<Result> results,
425 final int limit, final boolean hasMore) throws IOException {
426 return hasMore;
427 }
428
429 @Override
430 public boolean postScannerNext(final ObserverContext<RegionCoprocessorEnvironment> e,
431 final InternalScanner s, final List<Result> results, final int limit,
432 final boolean hasMore) throws IOException {
433 return hasMore;
434 }
435
436 @Override
437 public boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> e,
438 final InternalScanner s, final byte[] currentRow, final int offset, final short length,
439 final boolean hasMore) throws IOException {
440 return hasMore;
441 }
442
443 @Override
444 public void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> e,
445 final InternalScanner s) throws IOException {
446 }
447
448 @Override
449 public void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment> e,
450 final InternalScanner s) throws IOException {
451 }
452
453
454
455
456 @Override
457 public void preWALRestore(ObserverContext<? extends RegionCoprocessorEnvironment> env,
458 HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException {
459 }
460
461 @Override
462 public void preWALRestore(ObserverContext<RegionCoprocessorEnvironment> env, HRegionInfo info,
463 HLogKey logKey, WALEdit logEdit) throws IOException {
464 preWALRestore(env, info, (WALKey)logKey, logEdit);
465 }
466
467
468
469
470 @Override
471 public void postWALRestore(ObserverContext<? extends RegionCoprocessorEnvironment> env,
472 HRegionInfo info, WALKey logKey, WALEdit logEdit) throws IOException {
473 }
474
475 @Override
476 public void postWALRestore(ObserverContext<RegionCoprocessorEnvironment> env,
477 HRegionInfo info, HLogKey logKey, WALEdit logEdit) throws IOException {
478 postWALRestore(env, info, (WALKey)logKey, logEdit);
479 }
480
481 @Override
482 public void preBulkLoadHFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
483 List<Pair<byte[], String>> familyPaths) throws IOException {
484 }
485
486 @Override
487 public void preCommitStoreFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
488 final byte[] family, final List<Pair<Path, Path>> pairs) throws IOException {
489 }
490
491 @Override
492 public void postCommitStoreFile(final ObserverContext<RegionCoprocessorEnvironment> ctx,
493 final byte[] family, Path srcPath, Path dstPath) throws IOException {
494 }
495
496 @Override
497 public boolean postBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
498 List<Pair<byte[], String>> stagingFamilyPaths, Map<byte[], List<Path>> finalPaths,
499 boolean hasLoaded) throws IOException {
500 return postBulkLoadHFile(ctx, stagingFamilyPaths, hasLoaded);
501 }
502
503 @Override
504 public boolean postBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx,
505 List<Pair<byte[], String>> stagingFamilyPaths, boolean hasLoaded) throws IOException {
506 return hasLoaded;
507 }
508
509 @Override
510 public Reader preStoreFileReaderOpen(ObserverContext<RegionCoprocessorEnvironment> ctx,
511 FileSystem fs, Path p, FSDataInputStreamWrapper in, long size, CacheConfig cacheConf,
512 Reference r, Reader reader) throws IOException {
513 return reader;
514 }
515
516 @Override
517 public Reader postStoreFileReaderOpen(ObserverContext<RegionCoprocessorEnvironment> ctx,
518 FileSystem fs, Path p, FSDataInputStreamWrapper in, long size, CacheConfig cacheConf,
519 Reference r, Reader reader) throws IOException {
520 return reader;
521 }
522
523 @Override
524 public Cell postMutationBeforeWAL(ObserverContext<RegionCoprocessorEnvironment> ctx,
525 MutationType opType, Mutation mutation, Cell oldCell, Cell newCell) throws IOException {
526 return newCell;
527 }
528
529 @Override
530 public void postStartRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
531 Operation op) throws IOException {
532 }
533
534 @Override
535 public void postCloseRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
536 Operation op) throws IOException {
537 }
538
539 @Override
540 public DeleteTracker postInstantiateDeleteTracker(
541 final ObserverContext<RegionCoprocessorEnvironment> ctx, DeleteTracker delTracker)
542 throws IOException {
543 return delTracker;
544 }
545 }