001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.quotas.policies; 019 020import java.io.IOException; 021import java.util.List; 022import org.apache.hadoop.fs.FileSystem; 023import org.apache.hadoop.hbase.client.Mutation; 024import org.apache.hadoop.hbase.quotas.SpaceLimitingException; 025import org.apache.hadoop.hbase.quotas.SpaceViolationPolicyEnforcement; 026import org.apache.yetus.audience.InterfaceAudience; 027 028/** 029 * A {@link SpaceViolationPolicyEnforcement} which can be treated as a singleton. When a quota is 030 * not defined on a table or we lack quota information, we want to avoid creating a policy, keeping 031 * this path fast. 032 */ 033@InterfaceAudience.Private 034public final class MissingSnapshotViolationPolicyEnforcement 035 extends AbstractViolationPolicyEnforcement { 036 private static final MissingSnapshotViolationPolicyEnforcement SINGLETON = 037 new MissingSnapshotViolationPolicyEnforcement(); 038 039 private MissingSnapshotViolationPolicyEnforcement() { 040 } 041 042 public static SpaceViolationPolicyEnforcement getInstance() { 043 return SINGLETON; 044 } 045 046 @Override 047 public boolean shouldCheckBulkLoads() { 048 return false; 049 } 050 051 @Override 052 public long computeBulkLoadSize(FileSystem fs, List<String> paths) throws SpaceLimitingException { 053 long size = 0; 054 for (String path : paths) { 055 size += getFileSize(fs, path); 056 } 057 return size; 058 } 059 060 @Override 061 public void enable() throws IOException { 062 } 063 064 @Override 065 public void disable() throws IOException { 066 } 067 068 @Override 069 public void check(Mutation m) throws SpaceLimitingException { 070 } 071 072 @Override 073 public String getPolicyName() { 074 return "NoQuota"; 075 } 076}