001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to you under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.hadoop.hbase.quotas.policies; 018 019import java.util.Objects; 020 021import org.apache.hadoop.hbase.TableName; 022import org.apache.yetus.audience.InterfaceAudience; 023import org.apache.yetus.audience.InterfaceStability; 024import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; 025import org.apache.hadoop.hbase.quotas.SpaceViolationPolicyEnforcement; 026import org.apache.hadoop.hbase.regionserver.RegionServerServices; 027 028/** 029 * Abstract implementation for {@link SpaceViolationPolicyEnforcement}. 030 */ 031@InterfaceAudience.Private 032@InterfaceStability.Evolving 033public abstract class AbstractViolationPolicyEnforcement 034 implements SpaceViolationPolicyEnforcement { 035 036 RegionServerServices rss; 037 TableName tableName; 038 SpaceQuotaSnapshot quotaSnapshot; 039 040 public void setRegionServerServices(RegionServerServices rss) { 041 this.rss = Objects.requireNonNull(rss); 042 } 043 044 public void setTableName(TableName tableName) { 045 this.tableName = tableName; 046 } 047 048 public RegionServerServices getRegionServerServices() { 049 return this.rss; 050 } 051 052 public TableName getTableName() { 053 return this.tableName; 054 } 055 056 public void setQuotaSnapshot(SpaceQuotaSnapshot snapshot) { 057 this.quotaSnapshot = Objects.requireNonNull(snapshot); 058 } 059 060 @Override 061 public SpaceQuotaSnapshot getQuotaSnapshot() { 062 return this.quotaSnapshot; 063 } 064 065 @Override 066 public void initialize( 067 RegionServerServices rss, TableName tableName, SpaceQuotaSnapshot snapshot) { 068 setRegionServerServices(rss); 069 setTableName(tableName); 070 setQuotaSnapshot(snapshot); 071 } 072 073 @Override 074 public boolean areCompactionsDisabled() { 075 return false; 076 } 077}