/** * 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()); assertNull(MetaTableLocator.getMetaRegionLocation(this.watcher)); for (RegionState.State state : RegionState.State.values()) { if (state.equals(RegionState.State.OPEN)) { continue; } MetaTableLocator.setMetaLocation(this.watcher, SN, state); assertNull(MetaTableLocator.getMetaRegionLocation(this.watcher)); assertEquals(state, MetaTableLocator.getMetaRegionState(this.watcher).getState()); } MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPEN); assertEquals(SN, MetaTableLocator.getMetaRegionLocation(this.watcher)); assertEquals(RegionState.State.OPEN, MetaTableLocator.getMetaRegionState(this.watcher).getState()); MetaTableLocator.deleteMetaLocation(this.watcher); assertNull(MetaTableLocator.getMetaRegionState(this.watcher).getServerName()); assertEquals(RegionState.State.OFFLINE, MetaTableLocator.getMetaRegionState(this.watcher).getState()); assertNull(MetaTableLocator.getMetaRegionLocation(this.watcher)); }
if (replicaId == 0 && state.equals(State.SPLIT)) { for (HRegionLocation h : locations) { replicasToClose.add(h.getRegionInfo());
/** * 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(SN, mtl.getMetaRegionLocation(this.watcher)); assertEquals(RegionState.State.OPEN, MetaTableLocator.getMetaRegionState(this.watcher).getState()); mtl.deleteMetaLocation(this.watcher); assertNull(MetaTableLocator.getMetaRegionState(this.watcher).getServerName()); assertEquals(RegionState.State.OFFLINE, MetaTableLocator.getMetaRegionState(this.watcher).getState()); assertNull(mtl.getMetaRegionLocation(this.watcher)); }