1919
2020import java .io .IOException ;
2121import java .util .List ;
22+ import java .util .Map ;
2223import java .util .Optional ;
24+ import java .util .Set ;
2325import org .apache .hadoop .conf .Configuration ;
2426import org .apache .hadoop .hbase .CompareOperator ;
2527import org .apache .hadoop .hbase .CoprocessorEnvironment ;
2830import org .apache .hadoop .hbase .NamespaceDescriptor ;
2931import org .apache .hadoop .hbase .TableName ;
3032import org .apache .hadoop .hbase .client .Append ;
33+ import org .apache .hadoop .hbase .client .BalanceRequest ;
3134import org .apache .hadoop .hbase .client .Delete ;
3235import org .apache .hadoop .hbase .client .Mutation ;
3336import org .apache .hadoop .hbase .client .Put ;
5154import org .apache .hadoop .hbase .coprocessor .RegionServerObserver ;
5255import org .apache .hadoop .hbase .filter .ByteArrayComparable ;
5356import org .apache .hadoop .hbase .filter .Filter ;
57+ import org .apache .hadoop .hbase .net .Address ;
58+ import org .apache .hadoop .hbase .quotas .GlobalQuotaSettings ;
5459import org .apache .hadoop .hbase .regionserver .FlushLifeCycleTracker ;
5560import org .apache .hadoop .hbase .regionserver .MiniBatchOperationInProgress ;
61+ import org .apache .hadoop .hbase .replication .ReplicationPeerConfig ;
62+ import org .apache .hadoop .hbase .replication .SyncReplicationState ;
5663import org .apache .hadoop .hbase .util .Pair ;
5764import org .apache .hadoop .hbase .wal .WALEdit ;
5865import org .apache .yetus .audience .InterfaceAudience ;
@@ -241,13 +248,24 @@ public Optional<MasterObserver> getMasterObserver() {
241248 return Optional .of (this );
242249 }
243250
251+ @ Override public TableDescriptor preCreateTableRegionsInfos (
252+ ObserverContext <MasterCoprocessorEnvironment > ctx , TableDescriptor desc ) throws IOException {
253+ internalReadOnlyGuard ();
254+ return MasterObserver .super .preCreateTableRegionsInfos (ctx , desc );
255+ }
256+
244257 @ Override
245258 public void preCreateTable (ObserverContext <MasterCoprocessorEnvironment > ctx ,
246259 TableDescriptor desc , RegionInfo [] regions ) throws IOException {
247260 internalReadOnlyGuard ();
248261 MasterObserver .super .preCreateTable (ctx , desc , regions );
249262 }
250263
264+ @ Override public void preCreateTableAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
265+ TableDescriptor desc , RegionInfo [] regions ) throws IOException {
266+ MasterObserver .super .preCreateTableAction (ctx , desc , regions );
267+ }
268+
251269 @ Override
252270 public void preDeleteTable (ObserverContext <MasterCoprocessorEnvironment > ctx , TableName tableName )
253271 throws IOException {
@@ -284,6 +302,91 @@ public TableDescriptor preModifyTable(ObserverContext<MasterCoprocessorEnvironme
284302 return MasterObserver .super .preModifyTable (ctx , tableName , currentDescriptor , newDescriptor );
285303 }
286304
305+ @ Override
306+ public String preModifyTableStoreFileTracker (ObserverContext <MasterCoprocessorEnvironment > ctx ,
307+ TableName tableName , String dstSFT ) throws IOException {
308+ internalReadOnlyGuard ();
309+ return MasterObserver .super .preModifyTableStoreFileTracker (ctx , tableName , dstSFT );
310+ }
311+
312+ @ Override public String preModifyColumnFamilyStoreFileTracker (
313+ ObserverContext <MasterCoprocessorEnvironment > ctx , TableName tableName , byte [] family ,
314+ String dstSFT ) throws IOException {
315+ internalReadOnlyGuard ();
316+ return MasterObserver .super .preModifyColumnFamilyStoreFileTracker (ctx , tableName , family ,
317+ dstSFT );
318+ }
319+
320+ @ Override public void preModifyTableAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
321+ TableName tableName , TableDescriptor currentDescriptor , TableDescriptor newDescriptor )
322+ throws IOException {
323+ internalReadOnlyGuard ();
324+ MasterObserver .super .preModifyTableAction (ctx , tableName , currentDescriptor , newDescriptor );
325+ }
326+
327+ @ Override
328+ public void preSplitRegion (ObserverContext <MasterCoprocessorEnvironment > c , TableName tableName ,
329+ byte [] splitRow ) throws IOException {
330+ internalReadOnlyGuard ();
331+ MasterObserver .super .preSplitRegion (c , tableName , splitRow );
332+ }
333+
334+ @ Override public void preSplitRegionAction (ObserverContext <MasterCoprocessorEnvironment > c ,
335+ TableName tableName , byte [] splitRow ) throws IOException {
336+ internalReadOnlyGuard ();
337+ MasterObserver .super .preSplitRegionAction (c , tableName , splitRow );
338+ }
339+
340+ @ Override
341+ public void preSplitRegionBeforeMETAAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
342+ byte [] splitKey , List <Mutation > metaEntries ) throws IOException {
343+ internalReadOnlyGuard ();
344+ MasterObserver .super .preSplitRegionBeforeMETAAction (ctx , splitKey , metaEntries );
345+ }
346+
347+ @ Override
348+ public void preSplitRegionAfterMETAAction (ObserverContext <MasterCoprocessorEnvironment > ctx )
349+ throws IOException {
350+ internalReadOnlyGuard ();
351+ MasterObserver .super .preSplitRegionAfterMETAAction (ctx );
352+ }
353+
354+ @ Override public void preTruncateRegion (ObserverContext <MasterCoprocessorEnvironment > c ,
355+ RegionInfo regionInfo ){
356+ try {
357+ internalReadOnlyGuard ();
358+ } catch (IOException e ) {
359+ LOG .info ("Region truncation of region {} not allowed in read-only mode" ,
360+ regionInfo .getRegionNameAsString ());
361+ }
362+ MasterObserver .super .preTruncateRegion (c , regionInfo );
363+ }
364+
365+ @ Override public void preTruncateRegionAction (ObserverContext <MasterCoprocessorEnvironment > c ,
366+ RegionInfo regionInfo ){
367+ try {
368+ internalReadOnlyGuard ();
369+ } catch (IOException e ) {
370+ LOG .info ("Region truncation of region {} not allowed in read-only mode" ,
371+ regionInfo .getRegionNameAsString ());
372+ }
373+ MasterObserver .super .preTruncateRegionAction (c , regionInfo );
374+ }
375+
376+ @ Override
377+ public void preMergeRegionsAction (final ObserverContext <MasterCoprocessorEnvironment > ctx ,
378+ final RegionInfo [] regionsToMerge ) throws IOException {
379+ internalReadOnlyGuard ();
380+ MasterObserver .super .preMergeRegionsAction (ctx , regionsToMerge );
381+ }
382+
383+ @ Override
384+ public void preMergeRegionsCommitAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
385+ RegionInfo [] regionsToMerge , List <Mutation > metaEntries ) throws IOException {
386+ internalReadOnlyGuard ();
387+ MasterObserver .super .preMergeRegionsCommitAction (ctx , regionsToMerge , metaEntries );
388+ }
389+
287390 @ Override
288391 public void preSnapshot (ObserverContext <MasterCoprocessorEnvironment > ctx ,
289392 SnapshotDescription snapshot , TableDescriptor tableDescriptor ) throws IOException {
@@ -334,26 +437,168 @@ public void preDeleteNamespace(ObserverContext<MasterCoprocessorEnvironment> ctx
334437 MasterObserver .super .preDeleteNamespace (ctx , namespace );
335438 }
336439
440+ @ Override public void preMasterStoreFlush (ObserverContext <MasterCoprocessorEnvironment > ctx )
441+ throws IOException {
442+ internalReadOnlyGuard ();
443+ MasterObserver .super .preMasterStoreFlush (ctx );
444+ }
445+
337446 @ Override
338- public void preMergeRegionsAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
339- RegionInfo [] regionsToMerge ) throws IOException {
447+ public void preSetUserQuota (ObserverContext <MasterCoprocessorEnvironment > ctx , String userName ,
448+ GlobalQuotaSettings quotas ) throws IOException {
340449 internalReadOnlyGuard ();
341- MasterObserver .super .preMergeRegionsAction (ctx , regionsToMerge );
450+ MasterObserver .super .preSetUserQuota (ctx , userName , quotas );
342451 }
343452
344- /* ---- RegionServerObserver Overrides ---- */
345453 @ Override
346- public void preRollWALWriterRequest (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
454+ public void preSetUserQuota (ObserverContext <MasterCoprocessorEnvironment > ctx , String userName ,
455+ TableName tableName , GlobalQuotaSettings quotas ) throws IOException {
456+ internalReadOnlyGuard ();
457+ MasterObserver .super .preSetUserQuota (ctx , userName , tableName , quotas );
458+ }
459+
460+ @ Override
461+ public void preSetUserQuota (ObserverContext <MasterCoprocessorEnvironment > ctx , String userName ,
462+ String namespace , GlobalQuotaSettings quotas ) throws IOException {
463+ internalReadOnlyGuard ();
464+ MasterObserver .super .preSetUserQuota (ctx , userName , namespace , quotas );
465+ }
466+
467+ @ Override public void preSetTableQuota (ObserverContext <MasterCoprocessorEnvironment > ctx ,
468+ TableName tableName , GlobalQuotaSettings quotas ) throws IOException {
469+ internalReadOnlyGuard ();
470+ MasterObserver .super .preSetTableQuota (ctx , tableName , quotas );
471+ }
472+
473+ @ Override public void preSetNamespaceQuota (ObserverContext <MasterCoprocessorEnvironment > ctx ,
474+ String namespace , GlobalQuotaSettings quotas ) throws IOException {
475+ internalReadOnlyGuard ();
476+ MasterObserver .super .preSetNamespaceQuota (ctx , namespace , quotas );
477+ }
478+
479+ @ Override public void preSetRegionServerQuota (ObserverContext <MasterCoprocessorEnvironment > ctx ,
480+ String regionServer , GlobalQuotaSettings quotas ) throws IOException {
481+ internalReadOnlyGuard ();
482+ MasterObserver .super .preSetRegionServerQuota (ctx , regionServer , quotas );
483+ }
484+
485+ @ Override public void preMergeRegions (final ObserverContext <MasterCoprocessorEnvironment > ctx ,
486+ final RegionInfo [] regionsToMerge ) throws IOException {
487+ internalReadOnlyGuard ();
488+ MasterObserver .super .preMergeRegions (ctx , regionsToMerge );
489+ }
490+
491+ @ Override public void preMoveServersAndTables (ObserverContext <MasterCoprocessorEnvironment > ctx ,
492+ Set <Address > servers , Set <TableName > tables , String targetGroup ) throws IOException {
493+ internalReadOnlyGuard ();
494+ MasterObserver .super .preMoveServersAndTables (ctx , servers , tables , targetGroup );
495+ }
496+
497+ @ Override public void preMoveServers (ObserverContext <MasterCoprocessorEnvironment > ctx ,
498+ Set <Address > servers , String targetGroup ) throws IOException {
499+ internalReadOnlyGuard ();
500+ MasterObserver .super .preMoveServers (ctx , servers , targetGroup );
501+ }
502+
503+ @ Override public void preMoveTables (ObserverContext <MasterCoprocessorEnvironment > ctx ,
504+ Set <TableName > tables , String targetGroup ) throws IOException {
505+ internalReadOnlyGuard ();
506+ MasterObserver .super .preMoveTables (ctx , tables , targetGroup );
507+ }
508+
509+ @ Override
510+ public void preAddRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String name )
347511 throws IOException {
348512 internalReadOnlyGuard ();
349- RegionServerObserver .super .preRollWALWriterRequest (ctx );
513+ MasterObserver .super .preAddRSGroup (ctx , name );
514+ }
515+
516+ @ Override
517+ public void preRemoveRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String name )
518+ throws IOException {
519+ internalReadOnlyGuard ();
520+ MasterObserver .super .preRemoveRSGroup (ctx , name );
521+ }
522+
523+ @ Override
524+ public void preBalanceRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String groupName ,
525+ BalanceRequest request ) throws IOException {
526+ internalReadOnlyGuard ();
527+ MasterObserver .super .preBalanceRSGroup (ctx , groupName , request );
528+ }
529+
530+ @ Override public void preRemoveServers (ObserverContext <MasterCoprocessorEnvironment > ctx ,
531+ Set <Address > servers ) throws IOException {
532+ internalReadOnlyGuard ();
533+ MasterObserver .super .preRemoveServers (ctx , servers );
350534 }
351535
352536 @ Override
353- public void preClearCompactionQueues (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
537+ public void preRenameRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String oldName ,
538+ String newName ) throws IOException {
539+ internalReadOnlyGuard ();
540+ MasterObserver .super .preRenameRSGroup (ctx , oldName , newName );
541+ }
542+
543+ @ Override public void preUpdateRSGroupConfig (ObserverContext <MasterCoprocessorEnvironment > ctx ,
544+ String groupName , Map <String , String > configuration ) throws IOException {
545+ internalReadOnlyGuard ();
546+ MasterObserver .super .preUpdateRSGroupConfig (ctx , groupName , configuration );
547+ }
548+
549+ @ Override public void preAddReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
550+ String peerId , ReplicationPeerConfig peerConfig ) throws IOException {
551+ MasterObserver .super .preAddReplicationPeer (ctx , peerId , peerConfig );
552+ }
553+
554+ @ Override public void preRemoveReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
555+ String peerId ) throws IOException {
556+ internalReadOnlyGuard ();
557+ MasterObserver .super .preRemoveReplicationPeer (ctx , peerId );
558+ }
559+
560+ @ Override public void preEnableReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
561+ String peerId ) throws IOException {
562+ internalReadOnlyGuard ();
563+ MasterObserver .super .preEnableReplicationPeer (ctx , peerId );
564+ }
565+
566+ @ Override public void preDisableReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
567+ String peerId ) throws IOException {
568+ internalReadOnlyGuard ();
569+ MasterObserver .super .preDisableReplicationPeer (ctx , peerId );
570+ }
571+
572+ @ Override
573+ public void preUpdateReplicationPeerConfig (ObserverContext <MasterCoprocessorEnvironment > ctx ,
574+ String peerId , ReplicationPeerConfig peerConfig ) throws IOException {
575+ internalReadOnlyGuard ();
576+ MasterObserver .super .preUpdateReplicationPeerConfig (ctx , peerId , peerConfig );
577+ }
578+
579+ @ Override public void preTransitReplicationPeerSyncReplicationState (
580+ ObserverContext <MasterCoprocessorEnvironment > ctx , String peerId , SyncReplicationState state )
581+ throws IOException {
582+ internalReadOnlyGuard ();
583+ MasterObserver .super .preTransitReplicationPeerSyncReplicationState (ctx , peerId , state );
584+ }
585+
586+ @ Override public void preGrant (ObserverContext <MasterCoprocessorEnvironment > ctx ,
587+ UserPermission userPermission , boolean mergeExistingPermissions ) throws IOException {
588+ MasterObserver .super .preGrant (ctx , userPermission , mergeExistingPermissions );
589+ }
590+
591+ @ Override public void preRevoke (ObserverContext <MasterCoprocessorEnvironment > ctx ,
592+ UserPermission userPermission ) throws IOException {
593+ MasterObserver .super .preRevoke (ctx , userPermission );
594+ }
595+
596+ /* ---- RegionServerObserver Overrides ---- */
597+ @ Override
598+ public void preRollWALWriterRequest (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
354599 throws IOException {
355600 internalReadOnlyGuard ();
356- RegionServerObserver .super .preClearCompactionQueues (ctx );
601+ RegionServerObserver .super .preRollWALWriterRequest (ctx );
357602 }
358603
359604 @ Override
@@ -371,10 +616,10 @@ public void preReplicationSinkBatchMutate(ObserverContext<RegionServerCoprocesso
371616 }
372617
373618 @ Override
374- public void preClearRegionBlockCache (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
619+ public void preReplicateLogEntries (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
375620 throws IOException {
376621 internalReadOnlyGuard ();
377- RegionServerObserver .super .preClearRegionBlockCache (ctx );
622+ RegionServerObserver .super .preReplicateLogEntries (ctx );
378623 }
379624
380625 /* ---- EndpointObserver Overrides ---- */
0 commit comments