HBASE-26481 Consider rolling upgrading from old region replication framework (#3880)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / client / TestAsyncClientPushback.java
blobfd746d5b73cdfe27ee3ff264910ffccba4e835f7
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import java.io.IOException;
21 import java.util.concurrent.CompletableFuture;
22 import java.util.concurrent.CountDownLatch;
23 import java.util.concurrent.atomic.AtomicLong;
24 import org.apache.hadoop.hbase.HBaseClassTestRule;
25 import org.apache.hadoop.hbase.client.backoff.ClientBackoffPolicy;
26 import org.apache.hadoop.hbase.testclassification.ClientTests;
27 import org.apache.hadoop.hbase.testclassification.LargeTests;
28 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
29 import org.apache.hadoop.hbase.util.FutureUtils;
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.ClassRule;
33 import org.junit.experimental.categories.Category;
35 import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
37 @Category({ LargeTests.class, ClientTests.class })
38 public class TestAsyncClientPushback extends ClientPushbackTestBase {
40 @ClassRule
41 public static final HBaseClassTestRule CLASS_RULE =
42 HBaseClassTestRule.forClass(TestAsyncClientPushback.class);
44 private AsyncConnectionImpl conn;
46 private AsyncBufferedMutator mutator;
48 @Before
49 public void setUp() throws Exception {
50 conn =
51 (AsyncConnectionImpl) ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
52 mutator = conn.getBufferedMutator(tableName);
55 @After
56 public void tearDown() throws IOException {
57 Closeables.close(mutator, true);
58 Closeables.close(conn, true);
61 @Override
62 protected ClientBackoffPolicy getBackoffPolicy() throws IOException {
63 return conn.getBackoffPolicy();
66 @Override
67 protected ServerStatisticTracker getStatisticsTracker() throws IOException {
68 return conn.getStatisticsTracker().get();
71 @Override
72 protected MetricsConnection getConnectionMetrics() throws IOException {
73 return conn.getConnectionMetrics().get();
76 @Override
77 protected void mutate(Put put) throws IOException {
78 CompletableFuture<?> future = mutator.mutate(put);
79 mutator.flush();
80 future.join();
83 @Override
84 protected void mutate(Put put, AtomicLong endTime, CountDownLatch latch) throws IOException {
85 FutureUtils.addListener(mutator.mutate(put), (r, e) -> {
86 endTime.set(EnvironmentEdgeManager.currentTime());
87 latch.countDown();
88 });
89 mutator.flush();
92 @Override
93 protected void mutateRow(RowMutations mutations) throws IOException {
94 conn.getTable(tableName).mutateRow(mutations).join();