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.
- Parameters:
conf
- configuration
- Returns:
- HConnection object for
conf
- Throws:
ZooKeeperConnectionException
-
getMockedConnectionAndDecorate
public static ClusterConnection getMockedConnectionAndDecorate(Configuration conf,
AdminProtos.AdminService.BlockingInterface admin,
ClientProtos.ClientService.BlockingInterface client,
ServerName sn,
HRegionInfo hri)
throws IOException
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). 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.
- Parameters:
conf
- Configuration to use
admin
- 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
connection
hri
- HRegionInfo to include in the location returned when
getRegionLocator is called on the mocked connection
- Returns:
- Mock up a connection that returns a
Configuration
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.
- Throws:
IOException
-
getSpiedConnection
public static ClusterConnection getSpiedConnection(Configuration conf)
throws IOException
Get a Mockito spied-upon 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.
- Parameters:
conf
- configuration
- Returns:
- HConnection object for
conf
- Throws:
ZooKeeperConnectionException
IOException
- See Also:
{http://mockito.googlecode.com/svn/branches/1.6/javadoc/org/mockito/Mockito.html#spy(T)}
-
getSpiedClusterConnection
public static ClusterConnection getSpiedClusterConnection(Configuration conf)
throws IOException
- Throws:
IOException
-
getConnectionCount
public static int getConnectionCount()
- Returns:
- Count of extant connection instances