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
.util
.concurrent
.CompletableFuture
;
21 import org
.apache
.hadoop
.conf
.Configuration
;
22 import org
.apache
.hadoop
.hbase
.DoNotRetryIOException
;
23 import org
.apache
.hadoop
.hbase
.HConstants
;
24 import org
.apache
.hadoop
.hbase
.HRegionLocation
;
25 import org
.apache
.hadoop
.hbase
.RegionLocations
;
26 import org
.apache
.hadoop
.hbase
.ServerName
;
27 import org
.apache
.hadoop
.hbase
.util
.FutureUtils
;
30 * Simple cluster registry inserted in place of our usual zookeeper based one.
32 class SimpleRegistry
extends DoNothingAsyncRegistry
{
34 private final ServerName metaHost
;
36 volatile boolean closed
= false;
38 private static final String META_HOST_CONFIG_NAME
= "hbase.client.simple-registry.meta.host";
40 private static final String DEFAULT_META_HOST
= "meta.example.org.16010,12345";
42 public static void setMetaHost(Configuration conf
, ServerName metaHost
) {
43 conf
.set(META_HOST_CONFIG_NAME
, metaHost
.getServerName());
46 public SimpleRegistry(Configuration conf
) {
48 this.metaHost
= ServerName
.valueOf(conf
.get(META_HOST_CONFIG_NAME
, DEFAULT_META_HOST
));
52 public CompletableFuture
<RegionLocations
> getMetaRegionLocation() {
54 return FutureUtils
.failedFuture(new DoNotRetryIOException("Client already closed"));
56 return CompletableFuture
.completedFuture(new RegionLocations(
57 new HRegionLocation(RegionInfoBuilder
.FIRST_META_REGIONINFO
, metaHost
)));
62 public CompletableFuture
<String
> getClusterId() {
64 return FutureUtils
.failedFuture(new DoNotRetryIOException("Client already closed"));
66 return CompletableFuture
.completedFuture(HConstants
.CLUSTER_ID_DEFAULT
);
71 public CompletableFuture
<Integer
> getCurrentNrHRS() {
73 return FutureUtils
.failedFuture(new DoNotRetryIOException("Client already closed"));
75 return CompletableFuture
.completedFuture(1);