/** * Checks if the meta region location is available. * @return true if meta region location is available, false if not */ public static boolean isLocationAvailable(ZKWatcher zkw) { return getMetaRegionLocation(zkw) != null; }
private ServerName getMetaLocationOrNull(HMaster master) { return MetaTableLocator.getMetaRegionLocation(master.getZooKeeper()); }
ServerName sn = null; while (true) { sn = getMetaRegionLocation(zkw, replicaId); if (sn != null || (System.currentTimeMillis() - startTime) > timeout - HConstants.SOCKET_RETRY_WAIT_MS) {
/** * Gets the meta regions and their locations for the given path and replica ID. * * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation * @param replicaId the ID of the replica * @return meta table regions and their locations. */ public static List<Pair<RegionInfo, ServerName>> getMetaRegionsAndLocations(ZKWatcher zkw, int replicaId) { ServerName serverName = getMetaRegionLocation(zkw, replicaId); List<Pair<RegionInfo, ServerName>> list = new ArrayList<>(1); list.add(new Pair<>(RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId), serverName)); return list; }
servers.add(getMetaRegionLocation(zkw, replicaId));
+ MetaTableLocator.getMetaRegionLocation(zkw)); Configuration conf = HBaseConfiguration.create(); int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM, for (int i = 1; i < numMetaReplicas; i++) { sb.append("\nRegion server holding hbase:meta, replicaId " + i + " " + MetaTableLocator.getMetaRegionLocation(zkw, i));
/** * Test waiting on meat w/ no timeout specified. */ @Test public void testNoTimeoutWaitForMeta() throws IOException, InterruptedException, KeeperException { ServerName hsa = MetaTableLocator.getMetaRegionLocation(watcher); assertNull(hsa); // Now test waiting on meta location getting set. Thread t = new WaitOnMetaThread(); startWaitAliveThenWaitItLives(t, 1); // Set a meta location. MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPEN); hsa = SN; // Join the thread... should exit shortly. t.join(); // Now meta is available. assertTrue(MetaTableLocator.getMetaRegionLocation(watcher).equals(hsa)); }
"assign out its replicas"); ServerName metaServername = MetaTableLocator.getMetaRegionLocation(this.master.getZooKeeper()); for (int i = 1; i < numReplicas; i++) {
/** * 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)); }
.getLiveRegionServerThreads().get(0).getRegionServer(); ZKWatcher zkw = hrs.getZooKeeper(); ServerName sn = MetaTableLocator.getMetaRegionLocation(zkw); if (sn != null && !masterAddr.equals(sn)) { return; hrs.getServerName(), HRegionInfo.FIRST_META_REGIONINFO); while (true) { sn = MetaTableLocator.getMetaRegionLocation(zkw); if (sn != null && sn.equals(hrs.getServerName()) && hrs.onlineRegions.containsKey(
if (Bytes.equals(RegionInfoBuilder.FIRST_META_REGIONINFO.getRegionName(), regionName)) { pair = new Pair<>(RegionInfoBuilder.FIRST_META_REGIONINFO, MetaTableLocator.getMetaRegionLocation(master.getZooKeeper()));
Set<ServerName> sns = new HashSet<ServerName>(); ServerName hbaseMetaServerName = MetaTableLocator.getMetaRegionLocation(TEST_UTIL.getZooKeeperWatcher()); LOG.info("HBASE:META DEPLOY: on " + hbaseMetaServerName); sns.add(hbaseMetaServerName);
/** * Checks if the meta region location is available. * @return true if meta region location is available, false if not */ public boolean isLocationAvailable(ZKWatcher zkw) { return getMetaRegionLocation(zkw) != null; }
/** * Checks if the meta region location is available. * @return true if meta region location is available, false if not */ public boolean isLocationAvailable(ZooKeeperWatcher zkw) { return getMetaRegionLocation(zkw) != null; }
/** * * @param zkw * @param replicaId * @return meta table regions and their locations. */ public List<Pair<HRegionInfo, ServerName>> getMetaRegionsAndLocations(ZooKeeperWatcher zkw, int replicaId) { ServerName serverName = getMetaRegionLocation(zkw, replicaId); List<Pair<HRegionInfo, ServerName>> list = new ArrayList<Pair<HRegionInfo, ServerName>>(); list.add(new Pair<HRegionInfo, ServerName>(RegionReplicaUtil.getRegionInfoForReplica( HRegionInfo.FIRST_META_REGIONINFO, replicaId), serverName)); return list; }
/** * Gets the meta regions and their locations for the given path and replica ID. * * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation * @param replicaId the ID of the replica * @return meta table regions and their locations. */ public List<Pair<RegionInfo, ServerName>> getMetaRegionsAndLocations(ZKWatcher zkw, int replicaId) { ServerName serverName = getMetaRegionLocation(zkw, replicaId); List<Pair<RegionInfo, ServerName>> list = new ArrayList<>(1); list.add(new Pair<>(RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, replicaId), serverName)); return list; }
private ServerName getMetaLocationOrNull(HMaster master) { MetaTableLocator metaTableLocator = master.getMetaTableLocator(); return metaTableLocator == null ? null : metaTableLocator.getMetaRegionLocation(master.getZooKeeper()); }
private ServerName getMetaRegionServerName(int replicaId) throws IOException, KeeperException { ZooKeeperWatcher zkw = createZooKeeperWatcher(); ServerName sn = null; try { sn = new MetaTableLocator().getMetaRegionLocation(zkw, replicaId); } finally { zkw.close(); } return sn; }
/** * If hbase:meta is not assigned already, assign. * @throws InterruptedException * @throws IOException * @throws KeeperException */ private void verifyAndAssignMeta(final MasterProcedureEnv env) throws InterruptedException, IOException, KeeperException { MasterServices services = env.getMasterServices(); if (!isMetaAssignedQuickTest(env)) { services.getAssignmentManager().assignMeta(HRegionInfo.FIRST_META_REGIONINFO); } else if (serverName.equals(services.getMetaTableLocator(). getMetaRegionLocation(services.getZooKeeper()))) { // hbase:meta seems to be still alive on the server whom master is expiring // and thinks is dying. Let's re-assign the hbase:meta anyway. services.getAssignmentManager().assignMeta(HRegionInfo.FIRST_META_REGIONINFO); } else { LOG.info("Skip assigning hbase:meta because it is online at " + services.getMetaTableLocator().getMetaRegionLocation(services.getZooKeeper())); } }
/** * Test waiting on meat w/ no timeout specified. * @throws IOException * @throws InterruptedException * @throws KeeperException */ @Test public void testNoTimeoutWaitForMeta() throws IOException, InterruptedException, KeeperException { final MetaTableLocator mtl = new MetaTableLocator(); ServerName hsa = mtl.getMetaRegionLocation(watcher); assertNull(hsa); // Now test waiting on meta location getting set. Thread t = new WaitOnMetaThread(); startWaitAliveThenWaitItLives(t, 1); // Set a meta location. MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPEN); hsa = SN; // Join the thread... should exit shortly. t.join(); // Now meta is available. assertTrue(mtl.getMetaRegionLocation(watcher).equals(hsa)); }