public class HConnectionTestingUtility extends Object
ClusterConnection testing utility.| Constructor and Description |
|---|
HConnectionTestingUtility() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getConnectionCount() |
static ClusterConnection |
getMockedConnection(Configuration conf)
Get a Mocked
HConnection that goes with the passed conf
configuration instance. |
static ClusterConnection |
getMockedConnectionAndDecorate(Configuration conf,
AdminProtos.AdminService.BlockingInterface admin,
ClientProtos.ClientService.BlockingInterface client,
ServerName sn,
HRegionInfo hri)
Calls
getMockedConnection(Configuration) and then mocks a few
more of the popular ClusterConnection methods so they do 'normal'
operation (see return doc below for list). |
static ClusterConnection |
getSpiedClusterConnection(Configuration conf) |
static ClusterConnection |
getSpiedConnection(Configuration conf)
Get a Mockito spied-upon
ClusterConnection that goes with the passed
conf configuration instance. |
public static ClusterConnection getMockedConnection(Configuration conf) throws ZooKeeperConnectionException
HConnection that goes with the passed conf
configuration instance. Minimally the mock will return
conf when HConnection.getConfiguration() is invoked.
Be sure to shutdown the connection when done by calling
HConnectionManager.deleteConnection(Configuration) else it
will stick around; this is probably not what you want.conf - configurationconfZooKeeperConnectionExceptionpublic static ClusterConnection getMockedConnectionAndDecorate(Configuration conf, AdminProtos.AdminService.BlockingInterface admin, ClientProtos.ClientService.BlockingInterface client, ServerName sn, HRegionInfo hri) throws IOException
getMockedConnection(Configuration) and then mocks a few
more of the popular ClusterConnection methods so they do 'normal'
operation (see return doc below for list). Be sure to shutdown the
connection when done by calling
HConnectionManager.deleteConnection(Configuration) else it
will stick around; this is probably not what you want.conf - Configuration to useadmin - An AdminProtocol; can be null but is usually
itself a mock.client - A ClientProtocol; can be null but is usually
itself a mock.sn - ServerName to include in the region location returned by this
connectionhri - HRegionInfo to include in the location returned when
getRegionLocator is called on the mocked connectionConfiguration when
HConnection.getConfiguration() is called, a 'location' when
ClusterConnection.getRegionLocation(org.apache.hadoop.hbase.TableName, byte[], boolean)
is called,
and that returns the passed AdminProtos.AdminService.BlockingInterface instance when
ClusterConnection.getAdmin(ServerName) is called, returns the passed
ClientProtos.ClientService.BlockingInterface instance when
ClusterConnection.getClient(ServerName) is called (Be sure to call
HConnectionManager.deleteConnection(Configuration)
when done with this mocked Connection.IOExceptionpublic static ClusterConnection getSpiedConnection(Configuration conf) throws IOException
ClusterConnection that goes with the passed
conf configuration instance.
Be sure to shutdown the connection when done by calling
HConnectionManager.deleteConnection(Configuration) else it
will stick around; this is probably not what you want.conf - configurationconfZooKeeperConnectionExceptionIOException{http://mockito.googlecode.com/svn/branches/1.6/javadoc/org/mockito/Mockito.html#spy(T)}public static ClusterConnection getSpiedClusterConnection(Configuration conf) throws IOException
IOExceptionpublic static int getConnectionCount()