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