/** * Updates the location of the specified region to be the specified server. * <p> * Connects to the specified server which should be hosting the specified catalog region name to * perform the edit. * @param connection connection we're using * @param regionInfo region to update location of * @param sn Server name * @param openSeqNum the latest sequence number obtained when the region was open * @param masterSystemTime wall clock time from master if passed in the open region RPC * @throws IOException In particular could throw {@link java.net.ConnectException} if the server * is down on other end. */ private static void updateLocation(Connection connection, RegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime) throws IOException { // region replicas are kept in the primary region's row Put put = new Put(getMetaKeyForRegion(regionInfo), masterSystemTime); addRegionInfo(put, regionInfo); addLocation(put, sn, openSeqNum, regionInfo.getReplicaId()); putToMetaTable(connection, put); LOG.info("Updated row {} with server=", regionInfo.getRegionNameAsString(), sn); }
/** * Puts the specified RegionInfo into META with replica related columns */ public static void fixMetaHoleOnlineAndAddReplicas(Configuration conf, RegionInfo hri, Collection<ServerName> servers, int numReplicas) throws IOException { Connection conn = ConnectionFactory.createConnection(conf); Table meta = conn.getTable(TableName.META_TABLE_NAME); Put put = MetaTableAccessor.makePutFromRegionInfo(hri, EnvironmentEdgeManager.currentTime()); if (numReplicas > 1) { Random r = new Random(); ServerName[] serversArr = servers.toArray(new ServerName[servers.size()]); for (int i = 1; i < numReplicas; i++) { ServerName sn = serversArr[r.nextInt(serversArr.length)]; // the column added here is just to make sure the master is able to // see the additional replicas when it is asked to assign. The // final value of these columns will be different and will be updated // by the actual regionservers that start hosting the respective replicas MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), i); } } meta.put(put); meta.close(); conn.close(); }
Preconditions.checkArgument(state == State.OPEN && regionLocation != null, "Open region should be on a server"); MetaTableAccessor.addLocation(put, regionLocation, openSeqNum, replicaId);
addLocation(putOfMerged, sn, 1, mergedRegion.getReplicaId());
/** * Updates the location of the specified region to be the specified server. * <p> * Connects to the specified server which should be hosting the specified catalog region name to * perform the edit. * @param connection connection we're using * @param regionInfo region to update location of * @param sn Server name * @param openSeqNum the latest sequence number obtained when the region was open * @param masterSystemTime wall clock time from master if passed in the open region RPC * @throws IOException In particular could throw {@link java.net.ConnectException} if the server * is down on other end. */ private static void updateLocation(Connection connection, RegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime) throws IOException { // region replicas are kept in the primary region's row Put put = new Put(getMetaKeyForRegion(regionInfo), masterSystemTime); addRegionInfo(put, regionInfo); addLocation(put, sn, openSeqNum, regionInfo.getReplicaId()); putToMetaTable(connection, put); LOG.info("Updated row {} with server=", regionInfo.getRegionNameAsString(), sn); }
addLocation(putOfMerged, sn, 1, mergedRegion.getReplicaId());
/** * Updates the location of the specified region to be the specified server. * <p> * Connects to the specified server which should be hosting the specified catalog region name to * perform the edit. * @param connection connection we're using * @param regionInfo region to update location of * @param sn Server name * @param openSeqNum the latest sequence number obtained when the region was open * @param masterSystemTime wall clock time from master if passed in the open region RPC * @throws IOException In particular could throw {@link java.net.ConnectException} if the server * is down on other end. */ private static void updateLocation(Connection connection, RegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime) throws IOException { // region replicas are kept in the primary region's row Put put = new Put(getMetaKeyForRegion(regionInfo), masterSystemTime); addRegionInfo(put, regionInfo); addLocation(put, sn, openSeqNum, regionInfo.getReplicaId()); putToMetaTable(connection, put); LOG.info("Updated row {} with server=", regionInfo.getRegionNameAsString(), sn); }
/** * Puts the specified HRegionInfo into META with replica related columns */ public static void fixMetaHoleOnlineAndAddReplicas(Configuration conf, HRegionInfo hri, Collection<ServerName> servers, int numReplicas) throws IOException { Connection conn = ConnectionFactory.createConnection(conf); Table meta = conn.getTable(TableName.META_TABLE_NAME); Put put = MetaTableAccessor.makePutFromRegionInfo(hri); if (numReplicas > 1) { Random r = new Random(); ServerName[] serversArr = servers.toArray(new ServerName[servers.size()]); for (int i = 1; i < numReplicas; i++) { ServerName sn = serversArr[r.nextInt(serversArr.length)]; // the column added here is just to make sure the master is able to // see the additional replicas when it is asked to assign. The // final value of these columns will be different and will be updated // by the actual regionservers that start hosting the respective replicas MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), -1, i); } } meta.put(put); meta.close(); conn.close(); }
/** * Updates the location of the specified region to be the specified server. * <p> * Connects to the specified server which should be hosting the specified * catalog region name to perform the edit. * * @param connection connection we're using * @param regionInfo region to update location of * @param sn Server name * @param openSeqNum the latest sequence number obtained when the region was open * @param masterSystemTime wall clock time from master if passed in the open region RPC or -1 * @throws IOException In particular could throw {@link java.net.ConnectException} * if the server is down on other end. */ private static void updateLocation(final Connection connection, HRegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime) throws IOException { // use the maximum of what master passed us vs local time. long time = Math.max(EnvironmentEdgeManager.currentTime(), masterSystemTime); // region replicas are kept in the primary region's row Put put = new Put(getMetaKeyForRegion(regionInfo), time); addLocation(put, sn, openSeqNum, time, regionInfo.getReplicaId()); putToMetaTable(connection, put); LOG.info("Updated row " + regionInfo.getRegionNameAsString() + " with server=" + sn); }
/** * Adds a daughter region entry to meta. * @param regionInfo the region to put * @param sn the location of the region * @param openSeqNum the latest sequence number obtained when the region was open */ public static void addDaughter(final Connection connection, final HRegionInfo regionInfo, final ServerName sn, final long openSeqNum) throws NotAllMetaRegionsOnlineException, IOException { Put put = new Put(regionInfo.getRegionName()); addRegionInfo(put, regionInfo); if (sn != null) { addLocation(put, sn, openSeqNum, -1, regionInfo.getReplicaId()); } putToMetaTable(connection, put); LOG.info("Added daughter " + regionInfo.getEncodedName() + (sn == null? ", serverName=null": ", serverName=" + sn.toString())); }
Preconditions.checkArgument(state == State.OPEN && serverName != null, "Open region should be on a server"); MetaTableAccessor.addLocation(put, serverName, openSeqNum, -1, replicaId); info.append(", openSeqNum=").append(openSeqNum); info.append(", server=").append(serverName);
Put putB = makePutFromRegionInfo(splitB); addLocation(putA, sn, 1, -1, splitA.getReplicaId()); //new regions, openSeqNum = 1 is fine. addLocation(putB, sn, 1, -1, splitB.getReplicaId());
addLocation(putOfMerged, sn, 1, -1, mergedRegion.getReplicaId());
addLocation(putOfMerged, sn, 1, mergedRegion.getReplicaId());