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.client; 019 020import java.io.Closeable; 021import java.util.List; 022import java.util.concurrent.CompletableFuture; 023 024import org.apache.hadoop.conf.Configuration; 025import org.apache.hadoop.hbase.TableName; 026import org.apache.yetus.audience.InterfaceAudience; 027 028/** 029 * Used to communicate with a single HBase table in batches. Obtain an instance from a 030 * {@link AsyncConnection} and call {@link #close()} afterwards. 031 * <p> 032 * The implementation is required to be thread safe. 033 */ 034@InterfaceAudience.Public 035public interface AsyncBufferedMutator extends Closeable { 036 037 /** 038 * Gets the fully qualified table name instance of the table that this 039 * {@code AsyncBufferedMutator} writes to. 040 */ 041 TableName getName(); 042 043 /** 044 * Returns the {@link org.apache.hadoop.conf.Configuration} object used by this instance. 045 * <p> 046 * The reference returned is not a copy, so any change made to it will affect this instance. 047 */ 048 Configuration getConfiguration(); 049 050 /** 051 * Sends a {@link Mutation} to the table. The mutations will be buffered and sent over the wire as 052 * part of a batch. Currently only supports {@link Put} and {@link Delete} mutations. 053 * @param mutation The data to send. 054 */ 055 CompletableFuture<Void> mutate(Mutation mutation); 056 057 /** 058 * Send some {@link Mutation}s to the table. The mutations will be buffered and sent over the wire 059 * as part of a batch. There is no guarantee of sending entire content of {@code mutations} in a 060 * single batch, the implementations are free to break it up according to the write buffer 061 * capacity. 062 * @param mutations The data to send. 063 */ 064 List<CompletableFuture<Void>> mutate(List<? extends Mutation> mutations); 065 066 /** 067 * Executes all the buffered, asynchronous operations. 068 */ 069 void flush(); 070 071 /** 072 * Performs a {@link #flush()} and releases any resources held. 073 */ 074 @Override 075 void close(); 076 077 /** 078 * Returns the maximum size in bytes of the write buffer. 079 * <p> 080 * The default value comes from the configuration parameter {@code hbase.client.write.buffer}. 081 * @return The size of the write buffer in bytes. 082 */ 083 long getWriteBufferSize(); 084}