HBASE-26587 Introduce a new Admin API to change SFT implementation (#4030)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / master / MockNoopMasterServices.java
blobd53cf81fa835d32b3d6adb86e50a41df837d5d13
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.master;
20 import static org.mockito.Mockito.mock;
21 import java.io.IOException;
22 import java.util.List;
23 import org.apache.hadoop.conf.Configuration;
24 import org.apache.hadoop.fs.FileSystem;
25 import org.apache.hadoop.hbase.ChoreService;
26 import org.apache.hadoop.hbase.CoordinatedStateManager;
27 import org.apache.hadoop.hbase.ServerName;
28 import org.apache.hadoop.hbase.TableDescriptors;
29 import org.apache.hadoop.hbase.TableName;
30 import org.apache.hadoop.hbase.client.AsyncClusterConnection;
31 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
32 import org.apache.hadoop.hbase.client.Connection;
33 import org.apache.hadoop.hbase.client.MasterSwitchType;
34 import org.apache.hadoop.hbase.client.NormalizeTableFilterParams;
35 import org.apache.hadoop.hbase.client.RegionInfo;
36 import org.apache.hadoop.hbase.client.TableDescriptor;
37 import org.apache.hadoop.hbase.executor.ExecutorService;
38 import org.apache.hadoop.hbase.favored.FavoredNodesManager;
39 import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
40 import org.apache.hadoop.hbase.master.janitor.CatalogJanitor;
41 import org.apache.hadoop.hbase.master.locking.LockManager;
42 import org.apache.hadoop.hbase.master.normalizer.RegionNormalizerManager;
43 import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
44 import org.apache.hadoop.hbase.master.replication.ReplicationPeerManager;
45 import org.apache.hadoop.hbase.master.replication.SyncReplicationReplayWALManager;
46 import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
47 import org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer;
48 import org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost;
49 import org.apache.hadoop.hbase.procedure2.LockedResource;
50 import org.apache.hadoop.hbase.procedure2.Procedure;
51 import org.apache.hadoop.hbase.procedure2.ProcedureEvent;
52 import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
53 import org.apache.hadoop.hbase.quotas.MasterQuotaManager;
54 import org.apache.hadoop.hbase.replication.ReplicationException;
55 import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
56 import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
57 import org.apache.hadoop.hbase.replication.SyncReplicationState;
58 import org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager;
59 import org.apache.hadoop.hbase.security.access.AccessChecker;
60 import org.apache.hadoop.hbase.security.access.ZKPermissionWatcher;
61 import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
62 import org.apache.hbase.thirdparty.com.google.protobuf.Service;
64 public class MockNoopMasterServices implements MasterServices {
65 private final Configuration conf;
66 private final MetricsMaster metricsMaster;
68 public MockNoopMasterServices() {
69 this(null);
72 public MockNoopMasterServices(final Configuration conf) {
73 this.conf = conf;
74 this.metricsMaster = new MetricsMaster(new MetricsMasterWrapperImpl(null));
77 @Override
78 public void checkTableModifiable(TableName tableName) throws IOException {
79 //no-op
82 @Override
83 public long createTable(
84 final TableDescriptor desc,
85 final byte[][] splitKeys,
86 final long nonceGroup,
87 final long nonce) throws IOException {
88 // no-op
89 return -1;
92 @Override
93 public long createSystemTable(final TableDescriptor tableDescriptor) throws IOException {
94 return -1;
97 @Override
98 public AssignmentManager getAssignmentManager() {
99 return null;
102 @Override
103 public ExecutorService getExecutorService() {
104 return null;
107 @Override
108 public ChoreService getChoreService() {
109 return null;
112 @Override
113 public CatalogJanitor getCatalogJanitor() {
114 return null;
117 @Override
118 public MasterFileSystem getMasterFileSystem() {
119 return null;
122 @Override
123 public MasterWalManager getMasterWalManager() {
124 return null;
127 @Override
128 public MasterCoprocessorHost getMasterCoprocessorHost() {
129 return null;
132 @Override
133 public MasterQuotaManager getMasterQuotaManager() {
134 return null;
137 @Override public RegionNormalizerManager getRegionNormalizerManager() {
138 return null;
141 @Override
142 public ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() {
143 return null;
146 @Override
147 public MetricsMaster getMasterMetrics() {
148 return metricsMaster;
151 @Override
152 public ServerManager getServerManager() {
153 return null;
156 @Override
157 public ZKWatcher getZooKeeper() {
158 return null;
161 @Override
162 public CoordinatedStateManager getCoordinatedStateManager() {
163 return null;
166 @Override
167 public Connection getConnection() {
168 return null;
171 @Override
172 public Configuration getConfiguration() {
173 return conf;
176 @Override
177 public ServerName getServerName() {
178 return ServerName.valueOf("mock.master", 12345, 1);
181 @Override
182 public void abort(String why, Throwable e) {
183 //no-op
186 @Override
187 public boolean isAborted() {
188 return false;
191 private boolean stopped = false;
193 @Override
194 public void stop(String why) {
195 stopped = true;
198 @Override
199 public boolean isStopping() {
200 return stopped;
203 @Override
204 public boolean isStopped() {
205 return stopped;
208 @Override
209 public TableDescriptors getTableDescriptors() {
210 return null;
213 @Override
214 public boolean registerService(Service instance) {
215 return false;
218 @Override
219 public boolean abortProcedure(final long procId, final boolean mayInterruptIfRunning)
220 throws IOException {
221 return false; //To change body of implemented methods use File | Settings | File Templates.
224 @Override
225 public List<Procedure<?>> getProcedures() throws IOException {
226 return null; //To change body of implemented methods use File | Settings | File Templates.
229 @Override
230 public List<LockedResource> getLocks() throws IOException {
231 return null;
234 @Override
235 public List<TableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException {
236 return null; //To change body of implemented methods use File | Settings | File Templates.
239 @Override
240 public List<TableName> listTableNamesByNamespace(String name) throws IOException {
241 return null;
244 @Override
245 public long deleteTable(
246 final TableName tableName,
247 final long nonceGroup,
248 final long nonce) throws IOException {
249 return -1;
252 @Override
253 public long truncateTable(
254 final TableName tableName,
255 final boolean preserveSplits,
256 final long nonceGroup,
257 final long nonce) throws IOException {
258 return -1;
262 @Override
263 public long modifyTable(
264 final TableName tableName,
265 final TableDescriptor descriptor,
266 final long nonceGroup,
267 final long nonce) throws IOException {
268 return -1;
271 @Override
272 public long enableTable(
273 final TableName tableName,
274 final long nonceGroup,
275 final long nonce) throws IOException {
276 return -1;
279 @Override
280 public long disableTable(
281 TableName tableName,
282 final long nonceGroup,
283 final long nonce) throws IOException {
284 return -1;
287 @Override
288 public long addColumn(final TableName tableName, final ColumnFamilyDescriptor columnDescriptor,
289 final long nonceGroup, final long nonce) throws IOException {
290 return -1;
293 @Override
294 public long modifyColumn(final TableName tableName, final ColumnFamilyDescriptor descriptor,
295 final long nonceGroup, final long nonce) throws IOException {
296 return -1;
299 @Override
300 public long deleteColumn(final TableName tableName, final byte[] columnName,
301 final long nonceGroup, final long nonce) throws IOException {
302 return -1;
305 @Override
306 public long mergeRegions(
307 final RegionInfo[] regionsToMerge,
308 final boolean forcible,
309 final long nonceGroup,
310 final long nonce) throws IOException {
311 return -1;
314 @Override
315 public long splitRegion(
316 final RegionInfo regionInfo,
317 final byte[] splitRow,
318 final long nonceGroup,
319 final long nonce) throws IOException {
320 return -1;
323 @Override
324 public TableStateManager getTableStateManager() {
325 return mock(TableStateManager.class);
328 @Override
329 public boolean isActiveMaster() {
330 return true;
333 @Override
334 public boolean isInitialized() {
335 return false;
338 @Override
339 public boolean isInMaintenanceMode() {
340 return false;
343 @Override public boolean skipRegionManagementAction(String action) {
344 return false;
347 @Override
348 public long getLastMajorCompactionTimestamp(TableName table) throws IOException {
349 return 0;
352 @Override
353 public long getLastMajorCompactionTimestampForRegion(byte[] regionName) throws IOException {
354 return 0;
357 @Override
358 public ClusterSchema getClusterSchema() {
359 return null;
362 @Override
363 public LoadBalancer getLoadBalancer() {
364 return null;
367 @Override
368 public FavoredNodesManager getFavoredNodesManager() {
369 return null;
372 @Override
373 public SnapshotManager getSnapshotManager() {
374 return null;
377 @Override
378 public MasterProcedureManagerHost getMasterProcedureManagerHost() {
379 return null;
382 @Override
383 public boolean isSplitOrMergeEnabled(MasterSwitchType switchType) {
384 return false;
387 @Override
388 public long addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled)
389 throws ReplicationException {
390 return 0;
393 @Override
394 public long removeReplicationPeer(String peerId) throws ReplicationException {
395 return 0;
398 @Override
399 public long enableReplicationPeer(String peerId) throws ReplicationException, IOException {
400 return 0;
403 @Override
404 public long disableReplicationPeer(String peerId) throws ReplicationException, IOException {
405 return 0;
408 @Override
409 public ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws ReplicationException,
410 IOException {
411 return null;
414 @Override
415 public long updateReplicationPeerConfig(String peerId, ReplicationPeerConfig peerConfig)
416 throws ReplicationException, IOException {
417 return 0;
420 @Override
421 public List<ReplicationPeerDescription> listReplicationPeers(String regex)
422 throws ReplicationException, IOException {
423 return null;
426 @Override
427 public LockManager getLockManager() {
428 return null;
431 @Override
432 public String getRegionServerVersion(ServerName sn) {
433 return "0.0.0";
436 @Override
437 public void checkIfShouldMoveSystemRegionAsync() {
440 @Override
441 public String getClientIdAuditPrefix() {
442 return null;
445 @Override
446 public ProcedureEvent<?> getInitializedEvent() {
447 return null;
450 @Override
451 public FileSystem getFileSystem() {
452 return null;
455 @Override
456 public Connection createConnection(Configuration conf) throws IOException {
457 return null;
460 @Override
461 public ReplicationPeerManager getReplicationPeerManager() {
462 return null;
465 @Override
466 public boolean isClusterUp() {
467 return true;
470 public long transitReplicationPeerSyncReplicationState(String peerId,
471 SyncReplicationState clusterState) throws ReplicationException, IOException {
472 return 0;
475 @Override
476 public SyncReplicationReplayWALManager getSyncReplicationReplayWALManager() {
477 return null;
480 @Override
481 public AccessChecker getAccessChecker() {
482 return null;
485 @Override
486 public ZKPermissionWatcher getZKPermissionWatcher() {
487 return null;
490 @Override
491 public List<RegionPlan> executeRegionPlansWithThrottling(List<RegionPlan> plans) {
492 return null;
495 @Override
496 public AsyncClusterConnection getAsyncClusterConnection() {
497 return null;
500 @Override
501 public void runReplicationBarrierCleaner() {
504 @Override
505 public RSGroupInfoManager getRSGroupInfoManager() {
506 return null;
509 @Override
510 public boolean isBalancerOn() {
511 return false;
514 @Override
515 public boolean normalizeRegions(NormalizeTableFilterParams ntfp, boolean isHighPriority) {
516 return false;
519 @Override
520 public MetaLocationSyncer getMetaLocationSyncer() {
521 return null;
524 @Override
525 public long modifyTableStoreFileTracker(TableName tableName, String dstSFT, long nonceGroup,
526 long nonce) throws IOException {
527 return -1;
530 @Override
531 public long modifyColumnStoreFileTracker(TableName tableName, byte[] family, String dstSFT,
532 long nonceGroup, long nonce) throws IOException {
533 return -1;