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 ;
5661import org .apache .hadoop .hbase .regionserver .Store ;
5762import org .apache .hadoop .hbase .regionserver .StoreFile ;
5863import org .apache .hadoop .hbase .regionserver .compactions .CompactionLifeCycleTracker ;
64+ import org .apache .hadoop .hbase .replication .ReplicationPeerConfig ;
65+ import org .apache .hadoop .hbase .replication .SyncReplicationState ;
5966import org .apache .hadoop .hbase .util .Pair ;
6067import org .apache .hadoop .hbase .wal .WALEdit ;
6168import org .apache .yetus .audience .InterfaceAudience ;
@@ -252,13 +259,24 @@ public Optional<MasterObserver> getMasterObserver() {
252259 return Optional .of (this );
253260 }
254261
262+ @ Override public TableDescriptor preCreateTableRegionsInfos (
263+ ObserverContext <MasterCoprocessorEnvironment > ctx , TableDescriptor desc ) throws IOException {
264+ internalReadOnlyGuard ();
265+ return MasterObserver .super .preCreateTableRegionsInfos (ctx , desc );
266+ }
267+
255268 @ Override
256269 public void preCreateTable (ObserverContext <MasterCoprocessorEnvironment > ctx ,
257270 TableDescriptor desc , RegionInfo [] regions ) throws IOException {
258271 internalReadOnlyGuard ();
259272 MasterObserver .super .preCreateTable (ctx , desc , regions );
260273 }
261274
275+ @ Override public void preCreateTableAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
276+ TableDescriptor desc , RegionInfo [] regions ) throws IOException {
277+ MasterObserver .super .preCreateTableAction (ctx , desc , regions );
278+ }
279+
262280 @ Override
263281 public void preDeleteTable (ObserverContext <MasterCoprocessorEnvironment > ctx , TableName tableName )
264282 throws IOException {
@@ -295,6 +313,91 @@ public TableDescriptor preModifyTable(ObserverContext<MasterCoprocessorEnvironme
295313 return MasterObserver .super .preModifyTable (ctx , tableName , currentDescriptor , newDescriptor );
296314 }
297315
316+ @ Override
317+ public String preModifyTableStoreFileTracker (ObserverContext <MasterCoprocessorEnvironment > ctx ,
318+ TableName tableName , String dstSFT ) throws IOException {
319+ internalReadOnlyGuard ();
320+ return MasterObserver .super .preModifyTableStoreFileTracker (ctx , tableName , dstSFT );
321+ }
322+
323+ @ Override public String preModifyColumnFamilyStoreFileTracker (
324+ ObserverContext <MasterCoprocessorEnvironment > ctx , TableName tableName , byte [] family ,
325+ String dstSFT ) throws IOException {
326+ internalReadOnlyGuard ();
327+ return MasterObserver .super .preModifyColumnFamilyStoreFileTracker (ctx , tableName , family ,
328+ dstSFT );
329+ }
330+
331+ @ Override public void preModifyTableAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
332+ TableName tableName , TableDescriptor currentDescriptor , TableDescriptor newDescriptor )
333+ throws IOException {
334+ internalReadOnlyGuard ();
335+ MasterObserver .super .preModifyTableAction (ctx , tableName , currentDescriptor , newDescriptor );
336+ }
337+
338+ @ Override
339+ public void preSplitRegion (ObserverContext <MasterCoprocessorEnvironment > c , TableName tableName ,
340+ byte [] splitRow ) throws IOException {
341+ internalReadOnlyGuard ();
342+ MasterObserver .super .preSplitRegion (c , tableName , splitRow );
343+ }
344+
345+ @ Override public void preSplitRegionAction (ObserverContext <MasterCoprocessorEnvironment > c ,
346+ TableName tableName , byte [] splitRow ) throws IOException {
347+ internalReadOnlyGuard ();
348+ MasterObserver .super .preSplitRegionAction (c , tableName , splitRow );
349+ }
350+
351+ @ Override
352+ public void preSplitRegionBeforeMETAAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
353+ byte [] splitKey , List <Mutation > metaEntries ) throws IOException {
354+ internalReadOnlyGuard ();
355+ MasterObserver .super .preSplitRegionBeforeMETAAction (ctx , splitKey , metaEntries );
356+ }
357+
358+ @ Override
359+ public void preSplitRegionAfterMETAAction (ObserverContext <MasterCoprocessorEnvironment > ctx )
360+ throws IOException {
361+ internalReadOnlyGuard ();
362+ MasterObserver .super .preSplitRegionAfterMETAAction (ctx );
363+ }
364+
365+ @ Override public void preTruncateRegion (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 .preTruncateRegion (c , regionInfo );
374+ }
375+
376+ @ Override public void preTruncateRegionAction (ObserverContext <MasterCoprocessorEnvironment > c ,
377+ RegionInfo regionInfo ){
378+ try {
379+ internalReadOnlyGuard ();
380+ } catch (IOException e ) {
381+ LOG .info ("Region truncation of region {} not allowed in read-only mode" ,
382+ regionInfo .getRegionNameAsString ());
383+ }
384+ MasterObserver .super .preTruncateRegionAction (c , regionInfo );
385+ }
386+
387+ @ Override
388+ public void preMergeRegionsAction (final ObserverContext <MasterCoprocessorEnvironment > ctx ,
389+ final RegionInfo [] regionsToMerge ) throws IOException {
390+ internalReadOnlyGuard ();
391+ MasterObserver .super .preMergeRegionsAction (ctx , regionsToMerge );
392+ }
393+
394+ @ Override
395+ public void preMergeRegionsCommitAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
396+ RegionInfo [] regionsToMerge , List <Mutation > metaEntries ) throws IOException {
397+ internalReadOnlyGuard ();
398+ MasterObserver .super .preMergeRegionsCommitAction (ctx , regionsToMerge , metaEntries );
399+ }
400+
298401 @ Override
299402 public void preSnapshot (ObserverContext <MasterCoprocessorEnvironment > ctx ,
300403 SnapshotDescription snapshot , TableDescriptor tableDescriptor ) throws IOException {
@@ -345,26 +448,168 @@ public void preDeleteNamespace(ObserverContext<MasterCoprocessorEnvironment> ctx
345448 MasterObserver .super .preDeleteNamespace (ctx , namespace );
346449 }
347450
451+ @ Override public void preMasterStoreFlush (ObserverContext <MasterCoprocessorEnvironment > ctx )
452+ throws IOException {
453+ internalReadOnlyGuard ();
454+ MasterObserver .super .preMasterStoreFlush (ctx );
455+ }
456+
348457 @ Override
349- public void preMergeRegionsAction (ObserverContext <MasterCoprocessorEnvironment > ctx ,
350- RegionInfo [] regionsToMerge ) throws IOException {
458+ public void preSetUserQuota (ObserverContext <MasterCoprocessorEnvironment > ctx , String userName ,
459+ GlobalQuotaSettings quotas ) throws IOException {
351460 internalReadOnlyGuard ();
352- MasterObserver .super .preMergeRegionsAction (ctx , regionsToMerge );
461+ MasterObserver .super .preSetUserQuota (ctx , userName , quotas );
353462 }
354463
355- /* ---- RegionServerObserver Overrides ---- */
356464 @ Override
357- public void preRollWALWriterRequest (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
465+ public void preSetUserQuota (ObserverContext <MasterCoprocessorEnvironment > ctx , String userName ,
466+ TableName tableName , GlobalQuotaSettings quotas ) throws IOException {
467+ internalReadOnlyGuard ();
468+ MasterObserver .super .preSetUserQuota (ctx , userName , tableName , quotas );
469+ }
470+
471+ @ Override
472+ public void preSetUserQuota (ObserverContext <MasterCoprocessorEnvironment > ctx , String userName ,
473+ String namespace , GlobalQuotaSettings quotas ) throws IOException {
474+ internalReadOnlyGuard ();
475+ MasterObserver .super .preSetUserQuota (ctx , userName , namespace , quotas );
476+ }
477+
478+ @ Override public void preSetTableQuota (ObserverContext <MasterCoprocessorEnvironment > ctx ,
479+ TableName tableName , GlobalQuotaSettings quotas ) throws IOException {
480+ internalReadOnlyGuard ();
481+ MasterObserver .super .preSetTableQuota (ctx , tableName , quotas );
482+ }
483+
484+ @ Override public void preSetNamespaceQuota (ObserverContext <MasterCoprocessorEnvironment > ctx ,
485+ String namespace , GlobalQuotaSettings quotas ) throws IOException {
486+ internalReadOnlyGuard ();
487+ MasterObserver .super .preSetNamespaceQuota (ctx , namespace , quotas );
488+ }
489+
490+ @ Override public void preSetRegionServerQuota (ObserverContext <MasterCoprocessorEnvironment > ctx ,
491+ String regionServer , GlobalQuotaSettings quotas ) throws IOException {
492+ internalReadOnlyGuard ();
493+ MasterObserver .super .preSetRegionServerQuota (ctx , regionServer , quotas );
494+ }
495+
496+ @ Override public void preMergeRegions (final ObserverContext <MasterCoprocessorEnvironment > ctx ,
497+ final RegionInfo [] regionsToMerge ) throws IOException {
498+ internalReadOnlyGuard ();
499+ MasterObserver .super .preMergeRegions (ctx , regionsToMerge );
500+ }
501+
502+ @ Override public void preMoveServersAndTables (ObserverContext <MasterCoprocessorEnvironment > ctx ,
503+ Set <Address > servers , Set <TableName > tables , String targetGroup ) throws IOException {
504+ internalReadOnlyGuard ();
505+ MasterObserver .super .preMoveServersAndTables (ctx , servers , tables , targetGroup );
506+ }
507+
508+ @ Override public void preMoveServers (ObserverContext <MasterCoprocessorEnvironment > ctx ,
509+ Set <Address > servers , String targetGroup ) throws IOException {
510+ internalReadOnlyGuard ();
511+ MasterObserver .super .preMoveServers (ctx , servers , targetGroup );
512+ }
513+
514+ @ Override public void preMoveTables (ObserverContext <MasterCoprocessorEnvironment > ctx ,
515+ Set <TableName > tables , String targetGroup ) throws IOException {
516+ internalReadOnlyGuard ();
517+ MasterObserver .super .preMoveTables (ctx , tables , targetGroup );
518+ }
519+
520+ @ Override
521+ public void preAddRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String name )
358522 throws IOException {
359523 internalReadOnlyGuard ();
360- RegionServerObserver .super .preRollWALWriterRequest (ctx );
524+ MasterObserver .super .preAddRSGroup (ctx , name );
525+ }
526+
527+ @ Override
528+ public void preRemoveRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String name )
529+ throws IOException {
530+ internalReadOnlyGuard ();
531+ MasterObserver .super .preRemoveRSGroup (ctx , name );
532+ }
533+
534+ @ Override
535+ public void preBalanceRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String groupName ,
536+ BalanceRequest request ) throws IOException {
537+ internalReadOnlyGuard ();
538+ MasterObserver .super .preBalanceRSGroup (ctx , groupName , request );
539+ }
540+
541+ @ Override public void preRemoveServers (ObserverContext <MasterCoprocessorEnvironment > ctx ,
542+ Set <Address > servers ) throws IOException {
543+ internalReadOnlyGuard ();
544+ MasterObserver .super .preRemoveServers (ctx , servers );
361545 }
362546
363547 @ Override
364- public void preClearCompactionQueues (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
548+ public void preRenameRSGroup (ObserverContext <MasterCoprocessorEnvironment > ctx , String oldName ,
549+ String newName ) throws IOException {
550+ internalReadOnlyGuard ();
551+ MasterObserver .super .preRenameRSGroup (ctx , oldName , newName );
552+ }
553+
554+ @ Override public void preUpdateRSGroupConfig (ObserverContext <MasterCoprocessorEnvironment > ctx ,
555+ String groupName , Map <String , String > configuration ) throws IOException {
556+ internalReadOnlyGuard ();
557+ MasterObserver .super .preUpdateRSGroupConfig (ctx , groupName , configuration );
558+ }
559+
560+ @ Override public void preAddReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
561+ String peerId , ReplicationPeerConfig peerConfig ) throws IOException {
562+ MasterObserver .super .preAddReplicationPeer (ctx , peerId , peerConfig );
563+ }
564+
565+ @ Override public void preRemoveReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
566+ String peerId ) throws IOException {
567+ internalReadOnlyGuard ();
568+ MasterObserver .super .preRemoveReplicationPeer (ctx , peerId );
569+ }
570+
571+ @ Override public void preEnableReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
572+ String peerId ) throws IOException {
573+ internalReadOnlyGuard ();
574+ MasterObserver .super .preEnableReplicationPeer (ctx , peerId );
575+ }
576+
577+ @ Override public void preDisableReplicationPeer (ObserverContext <MasterCoprocessorEnvironment > ctx ,
578+ String peerId ) throws IOException {
579+ internalReadOnlyGuard ();
580+ MasterObserver .super .preDisableReplicationPeer (ctx , peerId );
581+ }
582+
583+ @ Override
584+ public void preUpdateReplicationPeerConfig (ObserverContext <MasterCoprocessorEnvironment > ctx ,
585+ String peerId , ReplicationPeerConfig peerConfig ) throws IOException {
586+ internalReadOnlyGuard ();
587+ MasterObserver .super .preUpdateReplicationPeerConfig (ctx , peerId , peerConfig );
588+ }
589+
590+ @ Override public void preTransitReplicationPeerSyncReplicationState (
591+ ObserverContext <MasterCoprocessorEnvironment > ctx , String peerId , SyncReplicationState state )
592+ throws IOException {
593+ internalReadOnlyGuard ();
594+ MasterObserver .super .preTransitReplicationPeerSyncReplicationState (ctx , peerId , state );
595+ }
596+
597+ @ Override public void preGrant (ObserverContext <MasterCoprocessorEnvironment > ctx ,
598+ UserPermission userPermission , boolean mergeExistingPermissions ) throws IOException {
599+ MasterObserver .super .preGrant (ctx , userPermission , mergeExistingPermissions );
600+ }
601+
602+ @ Override public void preRevoke (ObserverContext <MasterCoprocessorEnvironment > ctx ,
603+ UserPermission userPermission ) throws IOException {
604+ MasterObserver .super .preRevoke (ctx , userPermission );
605+ }
606+
607+ /* ---- RegionServerObserver Overrides ---- */
608+ @ Override
609+ public void preRollWALWriterRequest (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
365610 throws IOException {
366611 internalReadOnlyGuard ();
367- RegionServerObserver .super .preClearCompactionQueues (ctx );
612+ RegionServerObserver .super .preRollWALWriterRequest (ctx );
368613 }
369614
370615 @ Override
@@ -382,10 +627,10 @@ public void preReplicationSinkBatchMutate(ObserverContext<RegionServerCoprocesso
382627 }
383628
384629 @ Override
385- public void preClearRegionBlockCache (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
630+ public void preReplicateLogEntries (ObserverContext <RegionServerCoprocessorEnvironment > ctx )
386631 throws IOException {
387632 internalReadOnlyGuard ();
388- RegionServerObserver .super .preClearRegionBlockCache (ctx );
633+ RegionServerObserver .super .preReplicateLogEntries (ctx );
389634 }
390635
391636 /* ---- EndpointObserver Overrides ---- */
0 commit comments