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.master.balancer; 019 020import java.io.IOException; 021import java.util.Collection; 022import java.util.Collections; 023import java.util.List; 024import java.util.Map; 025import java.util.function.Predicate; 026import java.util.function.Supplier; 027import org.apache.hadoop.conf.Configuration; 028import org.apache.hadoop.hbase.HDFSBlocksDistribution; 029import org.apache.hadoop.hbase.ServerMetrics; 030import org.apache.hadoop.hbase.ServerName; 031import org.apache.hadoop.hbase.TableName; 032import org.apache.hadoop.hbase.client.BalancerDecision; 033import org.apache.hadoop.hbase.client.BalancerRejection; 034import org.apache.hadoop.hbase.client.Connection; 035import org.apache.hadoop.hbase.client.RegionInfo; 036import org.apache.hadoop.hbase.client.TableDescriptor; 037 038public class DummyClusterInfoProvider implements ClusterInfoProvider { 039 040 private volatile Configuration conf; 041 042 public DummyClusterInfoProvider(Configuration conf) { 043 this.conf = conf; 044 } 045 046 @Override 047 public Configuration getConfiguration() { 048 return conf; 049 } 050 051 @Override 052 public Connection getConnection() { 053 return null; 054 } 055 056 @Override 057 public List<RegionInfo> getAssignedRegions() { 058 return Collections.emptyList(); 059 } 060 061 @Override 062 public void unassign(RegionInfo regionInfo) throws IOException { 063 } 064 065 @Override 066 public TableDescriptor getTableDescriptor(TableName tableName) throws IOException { 067 return null; 068 } 069 070 @Override 071 public int getNumberOfTables() throws IOException { 072 return 0; 073 } 074 075 @Override 076 public HDFSBlocksDistribution computeHDFSBlocksDistribution(Configuration conf, 077 TableDescriptor tableDescriptor, RegionInfo regionInfo) throws IOException { 078 return new HDFSBlocksDistribution(); 079 } 080 081 @Override 082 public boolean hasRegionReplica(Collection<RegionInfo> regions) throws IOException { 083 return false; 084 } 085 086 @Override 087 public List<ServerName> getOnlineServersList() { 088 return Collections.emptyList(); 089 } 090 091 @Override 092 public List<ServerName> getOnlineServersListWithPredicator(List<ServerName> servers, 093 Predicate<ServerMetrics> filter) { 094 return Collections.emptyList(); 095 } 096 097 @Override 098 public Map<ServerName, List<RegionInfo>> getSnapShotOfAssignment(Collection<RegionInfo> regions) { 099 return Collections.emptyMap(); 100 } 101 102 @Override 103 public boolean isOffPeakHour() { 104 return false; 105 } 106 107 @Override 108 public void recordBalancerDecision(Supplier<BalancerDecision> decision) { 109 } 110 111 @Override 112 public void recordBalancerRejection(Supplier<BalancerRejection> rejection) { 113 } 114 115 @Override 116 public void onConfigurationChange(Configuration conf) { 117 this.conf = conf; 118 } 119 120 @Override 121 public ServerMetrics getLoad(ServerName serverName) { 122 return null; 123 } 124}