@Override public void run() { this.assignmentManager.assign(this.regionserver, this.regions); } }
@Override public Object call() throws Exception { assignmentManager.assign(hri, true, true, true); return null; } }
/** * Assigns the META region. * <p> * Assumes that META is currently closed and is not being actively served by * any RegionServer. * <p> * Forcibly assigns META to a random RegionServer. */ public void assignMeta() { // Force assignment to a random server assign(HRegionInfo.FIRST_META_REGIONINFO, true); }
public void assign(HRegionInfo region, boolean setOfflineInZK, boolean forceNewPlan) { assign(region, setOfflineInZK, forceNewPlan, false); }
@Override public Object call() throws Exception { assignmentManager.assign(hri, true, newPlan); return null; } }
public void assignRegion(HRegionInfo hri) { assignmentManager.assign(hri, true); }
public void assignRegion(HRegionInfo hri) { assignmentManager.assign(hri, true); }
/** * Assigns the specified region. * <p> * If a RegionPlan is available with a valid destination then it will be used * to determine what server region is assigned to. If no RegionPlan is * available, region will be assigned to a random available server. * <p> * Updates the RegionState and sends the OPEN RPC. * <p> * This will only succeed if the region is in transition and in a CLOSED or * OFFLINE state or not in transition (in-memory not zk), and of course, the * chosen server is up and running (It may have just crashed!). If the * in-memory checks pass, the zk node is forced to OFFLINE before assigning. * * @param region server to be assigned * @param setOfflineInZK whether ZK node should be created/transitioned to an * OFFLINE state before assigning the region */ public void assign(HRegionInfo region, boolean setOfflineInZK) { assign(region, setOfflineInZK, false); }
/** * Assigns the specified region. * <p> * If a RegionPlan is available with a valid destination then it will be used * to determine what server region is assigned to. If no RegionPlan is * available, region will be assigned to a random available server. * <p> * Updates the RegionState and sends the OPEN RPC. * <p> * This will only succeed if the region is in transition and in a CLOSED or * OFFLINE state or not in transition (in-memory not zk), and of course, the * chosen server is up and running (It may have just crashed!). If the * in-memory checks pass, the zk node is forced to OFFLINE before assigning. * * @param region server to be assigned * @param setOfflineInZK whether ZK node should be created/transitioned to an * OFFLINE state before assigning the region */ public void assign(HRegionInfo region, boolean setOfflineInZK) { assign(region, setOfflineInZK, false); }
@Override public void run() { try { if (!assignmentManager.assign(regionserver, regions)) { failedPlans.put(regionserver, regions); } } catch (Throwable t) { LOG.warn("Failed bulking assigning " + regions.size() + " region(s) to " + regionserver.getServerName() + ", and continue to bulk assign others", t); failedPlans.put(regionserver, regions); } } }
/** * Assigns the ROOT region. * <p> * Assumes that ROOT is currently closed and is not being actively served by * any RegionServer. * <p> * Forcibly unsets the current root region location in ZooKeeper and assigns * ROOT to a random RegionServer. * @throws KeeperException */ public void assignRoot() throws KeeperException { RootLocationEditor.deleteRootLocation(this.master.getZooKeeper()); assign(HRegionInfo.ROOT_REGIONINFO, true); }
/** * Triggers a bulk assignment of the specified regions * * @param assignmentManager the Assignment Manger * @param regionInfos the list of regions to assign * @throws IOException if an error occurred during the assignment */ public static void assignRegions(final AssignmentManager assignmentManager, final List<HRegionInfo> regionInfos) throws IOException { try { assignmentManager.getRegionStates().createRegionStates(regionInfos); assignmentManager.assign(regionInfos); } catch (InterruptedException e) { LOG.error("Caught " + e + " during round-robin assignment"); InterruptedIOException ie = new InterruptedIOException(e.getMessage()); ie.initCause(e); throw ie; } } }
private boolean assign(final MasterProcedureEnv env, final List<HRegionInfo> hris) throws InterruptedIOException { AssignmentManager am = env.getMasterServices().getAssignmentManager(); try { am.assign(hris); } catch (InterruptedException ie) { LOG.error("Caught " + ie + " during round-robin assignment"); throw (InterruptedIOException)new InterruptedIOException().initCause(ie); } catch (IOException ioe) { LOG.info("Caught " + ioe + " during region assignment, will retry"); return false; } return true; }
@Override public void process() throws IOException { ReentrantLock lock = locker.acquireLock(regionInfo.getEncodedName()); try { final int expectedVersion = ((ZkOpenRegionCoordination.ZkOpenRegionDetails) ord) .getVersion(); unassign(regionInfo, rsClosing, expectedVersion, null, useZKForAssignment, null); if (regionStates.isRegionOffline(regionInfo)) { assign(regionInfo, true); } } finally { lock.unlock(); } } });
/** * Assigns the hbase:meta region or a replica. * <p> * Assumes that hbase:meta is currently closed and is not being actively served by * any RegionServer. * <p> * Forcibly unsets the current meta region location in ZooKeeper and assigns * hbase:meta to a random RegionServer. * @param hri TODO * @throws KeeperException */ public void assignMeta(HRegionInfo hri) throws KeeperException { this.server.getMetaTableLocator().deleteMetaLocation(this.watcher, hri.getReplicaId()); assign(hri, true); }
/** * @param region * @param setOfflineInZK * @param forceNewPlan * @param hijack * - true new assignment is needed, false otherwise */ public void assign(HRegionInfo region, boolean setOfflineInZK, boolean forceNewPlan, boolean hijack) { // If hijack is true do not call disableRegionIfInRIT as // we have not yet moved the znode to OFFLINE state. if (!hijack && isDisabledorDisablingRegionInRIT(region)) { return; } if (this.serverManager.isClusterShutdown()) { LOG.info("Cluster shutdown is set; skipping assign of " + region.getRegionNameAsString()); return; } RegionState state = addToRegionsInTransition(region, hijack); synchronized (state) { assign(region, state, setOfflineInZK, forceNewPlan, hijack); } }
/** * Check individual daughter is up in .META.; fixup if its not. * @param result The contents of the parent row in .META. * @param qualifier Which daughter to check for. * @return 1 if the daughter is missing and fixed. Otherwise 0 * @throws IOException */ static int fixupDaughter(final Result result, final byte [] qualifier, final AssignmentManager assignmentManager, final CatalogTracker catalogTracker) throws IOException { HRegionInfo daughter = MetaReader.parseHRegionInfoFromCatalogResult(result, qualifier); if (daughter == null) return 0; if (isDaughterMissing(catalogTracker, daughter)) { LOG.info("Fixup; missing daughter " + daughter.getRegionNameAsString()); MetaEditor.addDaughter(catalogTracker, daughter, null); // TODO: Log WARN if the regiondir does not exist in the fs. If its not // there then something wonky about the split -- things will keep going // but could be missing references to parent region. // And assign it. assignmentManager.assign(daughter, true); return 1; } else { LOG.debug("Daughter " + daughter.getRegionNameAsString() + " present"); } return 0; }
@Override public void process() { LOG.debug("Handling CLOSED event for " + regionInfo.getEncodedName()); // Check if this table is being disabled or not if (this.assignmentManager.getZKTable(). isDisablingOrDisabledTable(this.regionInfo.getTableNameAsString())) { assignmentManager.offlineDisabledRegion(regionInfo); return; } // ZK Node is in CLOSED state, assign it. // TODO: Should we remove the region from RIT too? We don't? Makes for // a 'forcing' log message when we go to update state from CLOSED to OFFLINE assignmentManager.setOffline(regionInfo); // This below has to do w/ online enable/disable of a table assignmentManager.removeClosedRegion(regionInfo); assignmentManager.assign(regionInfo, true); } }
@Override public void process() { LOG.debug("Handling CLOSED event for " + regionInfo.getEncodedName()); // Check if this table is being disabled or not if (this.assignmentManager.getTableStateManager().isTableState(this.regionInfo.getTable(), ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING) || assignmentManager.getReplicasToClose().contains(regionInfo)) { assignmentManager.offlineDisabledRegion(regionInfo); return; } // ZK Node is in CLOSED state, assign it. assignmentManager.getRegionStates().updateRegionState( regionInfo, RegionState.State.CLOSED); // This below has to do w/ online enable/disable of a table assignmentManager.removeClosedRegion(regionInfo); assignmentManager.assign(regionInfo, true); } }