2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to you under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org
.apache
.hadoop
.hbase
.quotas
;
19 import java
.io
.IOException
;
20 import org
.apache
.hadoop
.hbase
.TableName
;
21 import org
.apache
.hadoop
.hbase
.client
.Connection
;
22 import org
.apache
.hadoop
.hbase
.client
.Put
;
23 import org
.apache
.hadoop
.hbase
.client
.Table
;
24 import org
.apache
.yetus
.audience
.InterfaceAudience
;
25 import org
.slf4j
.Logger
;
26 import org
.slf4j
.LoggerFactory
;
29 * A {@link SpaceQuotaSnapshotNotifier} which uses the hbase:quota table.
31 @InterfaceAudience.Private
32 public class TableSpaceQuotaSnapshotNotifier
implements SpaceQuotaSnapshotNotifier
{
33 private static final Logger LOG
= LoggerFactory
.getLogger(TableSpaceQuotaSnapshotNotifier
.class);
35 private Connection conn
;
38 public void transitionTable(
39 TableName tableName
, SpaceQuotaSnapshot snapshot
) throws IOException
{
40 final Put p
= QuotaTableUtil
.createPutForSpaceSnapshot(tableName
, snapshot
);
41 try (Table quotaTable
= conn
.getTable(QuotaTableUtil
.QUOTA_TABLE_NAME
)) {
42 if (LOG
.isTraceEnabled()) {
43 LOG
.trace("Persisting a space quota snapshot " + snapshot
+ " for " + tableName
);
50 public void initialize(Connection conn
) {