use of org.apache.hadoop.hbase.zookeeper.MetaTableLocator in project hbase by apache.
the class TestMetaTableLocator method testMetaLookup.
/**
* Test normal operations
*/
@Test
public void testMetaLookup() throws IOException, InterruptedException, ServiceException, KeeperException {
final ClientProtos.ClientService.BlockingInterface client = Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
Mockito.when(client.get((RpcController) Mockito.any(), (GetRequest) Mockito.any())).thenReturn(GetResponse.newBuilder().build());
final MetaTableLocator mtl = new MetaTableLocator();
assertNull(mtl.getMetaRegionLocation(this.watcher));
for (RegionState.State state : RegionState.State.values()) {
if (state.equals(RegionState.State.OPEN))
continue;
MetaTableLocator.setMetaLocation(this.watcher, SN, state);
assertNull(mtl.getMetaRegionLocation(this.watcher));
assertEquals(state, MetaTableLocator.getMetaRegionState(this.watcher).getState());
}
MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPEN);
assertEquals(mtl.getMetaRegionLocation(this.watcher), SN);
assertEquals(RegionState.State.OPEN, MetaTableLocator.getMetaRegionState(this.watcher).getState());
mtl.deleteMetaLocation(this.watcher);
assertNull(MetaTableLocator.getMetaRegionState(this.watcher).getServerName());
assertEquals(MetaTableLocator.getMetaRegionState(this.watcher).getState(), RegionState.State.OFFLINE);
assertNull(mtl.getMetaRegionLocation(this.watcher));
}
Aggregations