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
.util
;
20 import java
.io
.IOException
;
21 import org
.apache
.hadoop
.conf
.Configuration
;
22 import org
.apache
.hadoop
.fs
.FileSystem
;
23 import org
.apache
.hadoop
.hbase
.ChoreService
;
24 import org
.apache
.hadoop
.hbase
.CoordinatedStateManager
;
25 import org
.apache
.hadoop
.hbase
.HBaseTestingUtility
;
26 import org
.apache
.hadoop
.hbase
.Server
;
27 import org
.apache
.hadoop
.hbase
.ServerName
;
28 import org
.apache
.hadoop
.hbase
.ZooKeeperConnectionException
;
29 import org
.apache
.hadoop
.hbase
.client
.AsyncClusterConnection
;
30 import org
.apache
.hadoop
.hbase
.client
.Connection
;
31 import org
.apache
.hadoop
.hbase
.log
.HBaseMarkers
;
32 import org
.apache
.hadoop
.hbase
.zookeeper
.ZKWatcher
;
33 import org
.slf4j
.Logger
;
34 import org
.slf4j
.LoggerFactory
;
37 * Basic mock Server for handler tests.
39 public class MockServer
implements Server
{
40 private static final Logger LOG
= LoggerFactory
.getLogger(MockServer
.class);
41 final static ServerName NAME
= ServerName
.valueOf("MockServer", 123, -1);
46 final HBaseTestingUtility htu
;
48 public MockServer() throws ZooKeeperConnectionException
, IOException
{
49 // Shutdown default constructor by making it private.
53 public MockServer(final HBaseTestingUtility htu
)
54 throws ZooKeeperConnectionException
, IOException
{
59 * @param htu Testing utility to use
60 * @param zkw If true, create a zkw.
61 * @throws ZooKeeperConnectionException
64 public MockServer(final HBaseTestingUtility htu
, final boolean zkw
)
65 throws ZooKeeperConnectionException
, IOException
{
68 new ZKWatcher(htu
.getConfiguration(), NAME
.toString(), this, true):
73 public void abort(String why
, Throwable e
) {
74 LOG
.error(HBaseMarkers
.FATAL
, "Abort why=" + why
, e
);
80 public void stop(String why
) {
81 LOG
.debug("Stop why=" + why
);
86 public boolean isStopped() {
91 public Configuration
getConfiguration() {
92 return this.htu
.getConfiguration();
96 public ZKWatcher
getZooKeeper() {
101 public CoordinatedStateManager
getCoordinatedStateManager() {
106 public Connection
getConnection() {
111 public ServerName
getServerName() {
116 public boolean isAborted() {
121 public ChoreService
getChoreService() {
126 public FileSystem
getFileSystem() {
131 public boolean isStopping() {
136 public Connection
createConnection(Configuration conf
) throws IOException
{
141 public AsyncClusterConnection
getAsyncClusterConnection() {