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() {
72 public MockNoopMasterServices(final Configuration conf
) {
74 this.metricsMaster
= new MetricsMaster(new MetricsMasterWrapperImpl(null));
78 public void checkTableModifiable(TableName tableName
) throws IOException
{
83 public long createTable(
84 final TableDescriptor desc
,
85 final byte[][] splitKeys
,
86 final long nonceGroup
,
87 final long nonce
) throws IOException
{
93 public long createSystemTable(final TableDescriptor tableDescriptor
) throws IOException
{
98 public AssignmentManager
getAssignmentManager() {
103 public ExecutorService
getExecutorService() {
108 public ChoreService
getChoreService() {
113 public CatalogJanitor
getCatalogJanitor() {
118 public MasterFileSystem
getMasterFileSystem() {
123 public MasterWalManager
getMasterWalManager() {
128 public MasterCoprocessorHost
getMasterCoprocessorHost() {
133 public MasterQuotaManager
getMasterQuotaManager() {
137 @Override public RegionNormalizerManager
getRegionNormalizerManager() {
142 public ProcedureExecutor
<MasterProcedureEnv
> getMasterProcedureExecutor() {
147 public MetricsMaster
getMasterMetrics() {
148 return metricsMaster
;
152 public ServerManager
getServerManager() {
157 public ZKWatcher
getZooKeeper() {
162 public CoordinatedStateManager
getCoordinatedStateManager() {
167 public Connection
getConnection() {
172 public Configuration
getConfiguration() {
177 public ServerName
getServerName() {
178 return ServerName
.valueOf("mock.master", 12345, 1);
182 public void abort(String why
, Throwable e
) {
187 public boolean isAborted() {
191 private boolean stopped
= false;
194 public void stop(String why
) {
199 public boolean isStopping() {
204 public boolean isStopped() {
209 public TableDescriptors
getTableDescriptors() {
214 public boolean registerService(Service instance
) {
219 public boolean abortProcedure(final long procId
, final boolean mayInterruptIfRunning
)
221 return false; //To change body of implemented methods use File | Settings | File Templates.
225 public List
<Procedure
<?
>> getProcedures() throws IOException
{
226 return null; //To change body of implemented methods use File | Settings | File Templates.
230 public List
<LockedResource
> getLocks() throws IOException
{
235 public List
<TableDescriptor
> listTableDescriptorsByNamespace(String name
) throws IOException
{
236 return null; //To change body of implemented methods use File | Settings | File Templates.
240 public List
<TableName
> listTableNamesByNamespace(String name
) throws IOException
{
245 public long deleteTable(
246 final TableName tableName
,
247 final long nonceGroup
,
248 final long nonce
) throws IOException
{
253 public long truncateTable(
254 final TableName tableName
,
255 final boolean preserveSplits
,
256 final long nonceGroup
,
257 final long nonce
) throws IOException
{
263 public long modifyTable(
264 final TableName tableName
,
265 final TableDescriptor descriptor
,
266 final long nonceGroup
,
267 final long nonce
) throws IOException
{
272 public long enableTable(
273 final TableName tableName
,
274 final long nonceGroup
,
275 final long nonce
) throws IOException
{
280 public long disableTable(
282 final long nonceGroup
,
283 final long nonce
) throws IOException
{
288 public long addColumn(final TableName tableName
, final ColumnFamilyDescriptor columnDescriptor
,
289 final long nonceGroup
, final long nonce
) throws IOException
{
294 public long modifyColumn(final TableName tableName
, final ColumnFamilyDescriptor descriptor
,
295 final long nonceGroup
, final long nonce
) throws IOException
{
300 public long deleteColumn(final TableName tableName
, final byte[] columnName
,
301 final long nonceGroup
, final long nonce
) throws IOException
{
306 public long mergeRegions(
307 final RegionInfo
[] regionsToMerge
,
308 final boolean forcible
,
309 final long nonceGroup
,
310 final long nonce
) throws IOException
{
315 public long splitRegion(
316 final RegionInfo regionInfo
,
317 final byte[] splitRow
,
318 final long nonceGroup
,
319 final long nonce
) throws IOException
{
324 public TableStateManager
getTableStateManager() {
325 return mock(TableStateManager
.class);
329 public boolean isActiveMaster() {
334 public boolean isInitialized() {
339 public boolean isInMaintenanceMode() {
343 @Override public boolean skipRegionManagementAction(String action
) {
348 public long getLastMajorCompactionTimestamp(TableName table
) throws IOException
{
353 public long getLastMajorCompactionTimestampForRegion(byte[] regionName
) throws IOException
{
358 public ClusterSchema
getClusterSchema() {
363 public LoadBalancer
getLoadBalancer() {
368 public FavoredNodesManager
getFavoredNodesManager() {
373 public SnapshotManager
getSnapshotManager() {
378 public MasterProcedureManagerHost
getMasterProcedureManagerHost() {
383 public boolean isSplitOrMergeEnabled(MasterSwitchType switchType
) {
388 public long addReplicationPeer(String peerId
, ReplicationPeerConfig peerConfig
, boolean enabled
)
389 throws ReplicationException
{
394 public long removeReplicationPeer(String peerId
) throws ReplicationException
{
399 public long enableReplicationPeer(String peerId
) throws ReplicationException
, IOException
{
404 public long disableReplicationPeer(String peerId
) throws ReplicationException
, IOException
{
409 public ReplicationPeerConfig
getReplicationPeerConfig(String peerId
) throws ReplicationException
,
415 public long updateReplicationPeerConfig(String peerId
, ReplicationPeerConfig peerConfig
)
416 throws ReplicationException
, IOException
{
421 public List
<ReplicationPeerDescription
> listReplicationPeers(String regex
)
422 throws ReplicationException
, IOException
{
427 public LockManager
getLockManager() {
432 public String
getRegionServerVersion(ServerName sn
) {
437 public void checkIfShouldMoveSystemRegionAsync() {
441 public String
getClientIdAuditPrefix() {
446 public ProcedureEvent
<?
> getInitializedEvent() {
451 public FileSystem
getFileSystem() {
456 public Connection
createConnection(Configuration conf
) throws IOException
{
461 public ReplicationPeerManager
getReplicationPeerManager() {
466 public boolean isClusterUp() {
470 public long transitReplicationPeerSyncReplicationState(String peerId
,
471 SyncReplicationState clusterState
) throws ReplicationException
, IOException
{
476 public SyncReplicationReplayWALManager
getSyncReplicationReplayWALManager() {
481 public AccessChecker
getAccessChecker() {
486 public ZKPermissionWatcher
getZKPermissionWatcher() {
491 public List
<RegionPlan
> executeRegionPlansWithThrottling(List
<RegionPlan
> plans
) {
496 public AsyncClusterConnection
getAsyncClusterConnection() {
501 public void runReplicationBarrierCleaner() {
505 public RSGroupInfoManager
getRSGroupInfoManager() {
510 public boolean isBalancerOn() {
515 public boolean normalizeRegions(NormalizeTableFilterParams ntfp
, boolean isHighPriority
) {
520 public MetaLocationSyncer
getMetaLocationSyncer() {
525 public long modifyTableStoreFileTracker(TableName tableName
, String dstSFT
, long nonceGroup
,
526 long nonce
) throws IOException
{
531 public long modifyColumnStoreFileTracker(TableName tableName
, byte[] family
, String dstSFT
,
532 long nonceGroup
, long nonce
) throws IOException
{