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;
018
019import java.io.IOException;
020import java.util.Collection;
021import java.util.Map.Entry;
022import java.util.Set;
023
024import org.apache.yetus.audience.InterfaceAudience;
025
026/**
027 * Interface allowing various implementations of tracking files that have recently been archived to
028 * allow for the Master to notice changes to snapshot sizes for space quotas.
029 *
030 * This object needs to ensure that {@link #addArchivedFiles(Set)} and
031 * {@link #computeAndStoreSnapshotSizes(Collection)} are mutually exclusive. If a "full" computation
032 * is in progress, new changes being archived should be held.
033 */
034@InterfaceAudience.Private
035public interface FileArchiverNotifier {
036
037  /**
038   * Records a file and its size in bytes being moved to the archive directory.
039   *
040   * @param fileSizes A collection of file name to size in bytes
041   * @throws IOException If there was an IO-related error persisting the file size(s)
042   */
043  void addArchivedFiles(Set<Entry<String, Long>> fileSizes) throws IOException;
044
045  /**
046   * Computes the size of a table and all of its snapshots, recording new "full" sizes for each.
047   *
048   * @param currentSnapshots the current list of snapshots against this table
049   * @return The total size of all snapshots against this table.
050   * @throws IOException If there was an IO-related error computing or persisting the sizes.
051   */
052  long computeAndStoreSnapshotSizes(Collection<String> currentSnapshots) throws IOException;
053}