/** * Adds a hbase:meta row for each of the specified new regions. Initial state for new regions * is CLOSED. * @param connection connection we're using * @param regionInfos region information list * @throws IOException if problem connecting or updating meta */ public static void addRegionsToMeta(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException { addRegionsToMeta(connection, regionInfos, regionReplication, EnvironmentEdgeManager.currentTime()); }
/** * Adds a (single) hbase:meta row for the specified new region and its daughters. Note that this * does not add its daughter's as different rows, but adds information about the daughters * in the same row as the parent. Use * {@link #splitRegion(Connection, RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)} * if you want to do that. * @param connection connection we're using * @param regionInfo region information * @throws IOException if problem connecting or updating meta */ @VisibleForTesting public static void addRegionToMeta(Connection connection, RegionInfo regionInfo) throws IOException { addRegionsToMeta(connection, Collections.singletonList(regionInfo), 1); }
/** * Overwrites the specified regions from hbase:meta. Deletes old rows for the given regions and * adds new ones. Regions added back have state CLOSED. * @param connection connection we're using * @param regionInfos list of regions to be added to META */ public static void overwriteRegions(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException { // use master time for delete marker and the Put long now = EnvironmentEdgeManager.currentTime(); deleteRegions(connection, regionInfos, now); // Why sleep? This is the easiest way to ensure that the previous deletes does not // eclipse the following puts, that might happen in the same ts from the server. // See HBASE-9906, and HBASE-9879. Once either HBASE-9879, HBASE-8770 is fixed, // or HBASE-9905 is fixed and meta uses seqIds, we do not need the sleep. // // HBASE-13875 uses master timestamp for the mutations. The 20ms sleep is not needed addRegionsToMeta(connection, regionInfos, regionReplication, now + 1); LOG.info("Overwritten " + regionInfos.size() + " regions to Meta"); LOG.debug("Overwritten regions: {} ", regionInfos); }
/** * Add the specified set of regions to the hbase:meta table. */ private static void addRegionsToMeta(final MasterProcedureEnv env, final TableDescriptor tableDescriptor, final List<RegionInfo> regionInfos) throws IOException { MetaTableAccessor.addRegionsToMeta(env.getMasterServices().getConnection(), regionInfos, tableDescriptor.getRegionReplication()); }
private static void addRegionsToMeta(final MasterProcedureEnv env, final TableDescriptor tableDescriptor, final List<RegionInfo> regionInfos) throws IOException { MetaTableAccessor.addRegionsToMeta(env.getMasterServices().getConnection(), regionInfos, tableDescriptor.getRegionReplication()); } /**
MetaTableAccessor.addRegionsToMeta(conn, regionsToAdd, regionReplication); addRegionsToInMemoryStates(regionsToAdd, env, regionReplication);
/** * Adds a hbase:meta row for each of the specified new regions. Initial state for new regions * is CLOSED. * @param connection connection we're using * @param regionInfos region information list * @throws IOException if problem connecting or updating meta */ public static void addRegionsToMeta(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException { addRegionsToMeta(connection, regionInfos, regionReplication, EnvironmentEdgeManager.currentTime()); }
@Test public void testMetaLocationForRegionReplicasIsAddedAtTableCreation() throws IOException { long regionId = System.currentTimeMillis(); RegionInfo primary = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())) .setStartKey(HConstants.EMPTY_START_ROW) .setEndKey(HConstants.EMPTY_END_ROW) .setSplit(false) .setRegionId(regionId) .setReplicaId(0) .build(); Table meta = MetaTableAccessor.getMetaHTable(connection); try { List<RegionInfo> regionInfos = Lists.newArrayList(primary); MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3); assertEmptyMetaLocation(meta, primary.getRegionName(), 1); assertEmptyMetaLocation(meta, primary.getRegionName(), 2); } finally { meta.close(); } }
/** * Adds a (single) hbase:meta row for the specified new region and its daughters. Note that this * does not add its daughter's as different rows, but adds information about the daughters * in the same row as the parent. Use * {@link #splitRegion(Connection, RegionInfo, long, RegionInfo, RegionInfo, ServerName, int)} * if you want to do that. * @param connection connection we're using * @param regionInfo region information * @throws IOException if problem connecting or updating meta */ @VisibleForTesting public static void addRegionToMeta(Connection connection, RegionInfo regionInfo) throws IOException { addRegionsToMeta(connection, Collections.singletonList(regionInfo), 1); }
MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3);
MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3);
try { List<RegionInfo> regionInfos = Lists.newArrayList(parent); MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3);
/** * Overwrites the specified regions from hbase:meta. Deletes old rows for the given regions and * adds new ones. Regions added back have state CLOSED. * @param connection connection we're using * @param regionInfos list of regions to be added to META */ public static void overwriteRegions(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException { // use master time for delete marker and the Put long now = EnvironmentEdgeManager.currentTime(); deleteRegions(connection, regionInfos, now); // Why sleep? This is the easiest way to ensure that the previous deletes does not // eclipse the following puts, that might happen in the same ts from the server. // See HBASE-9906, and HBASE-9879. Once either HBASE-9879, HBASE-8770 is fixed, // or HBASE-9905 is fixed and meta uses seqIds, we do not need the sleep. // // HBASE-13875 uses master timestamp for the mutations. The 20ms sleep is not needed addRegionsToMeta(connection, regionInfos, regionReplication, now + 1); LOG.info("Overwritten " + regionInfos.size() + " regions to Meta"); LOG.debug("Overwritten regions: {} ", regionInfos); }
try { List<RegionInfo> regionInfos = Lists.newArrayList(primary); MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 3); MetaTableAccessor.removeRegionReplicasFromMeta(Sets.newHashSet(primary.getRegionName()), 1, 2, connection);
try (Table meta = MetaTableAccessor.getMetaHTable(connection)) { List<RegionInfo> regionInfos = Lists.newArrayList(regionInfo); MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 1);
try (Table meta = MetaTableAccessor.getMetaHTable(connection)) { List<RegionInfo> regionInfos = Lists.newArrayList(regionInfoA, regionInfoB); MetaTableAccessor.addRegionsToMeta(connection, regionInfos, 1);
/** * Adds a hbase:meta row for each of the specified new regions. * @param connection connection we're using * @param regionInfos region information list * @throws IOException if problem connecting or updating meta */ public static void addRegionsToMeta(Connection connection, List<HRegionInfo> regionInfos, int regionReplication) throws IOException { addRegionsToMeta(connection, regionInfos, regionReplication, HConstants.LATEST_TIMESTAMP); } /**
/** * Add the specified set of regions to the hbase:meta table. */ protected void addRegionsToMeta(final List<HRegionInfo> regionInfos, int regionReplication) throws IOException { MetaTableAccessor.addRegionsToMeta(this.server.getConnection(), regionInfos, regionReplication); } }
/** * Adds a hbase:meta row for each of the specified new regions. Initial state for new regions * is CLOSED. * @param connection connection we're using * @param regionInfos region information list * @throws IOException if problem connecting or updating meta */ public static void addRegionsToMeta(Connection connection, List<RegionInfo> regionInfos, int regionReplication) throws IOException { addRegionsToMeta(connection, regionInfos, regionReplication, EnvironmentEdgeManager.currentTime()); }
/** * Add the specified set of regions to the hbase:meta table. */ protected static void addRegionsToMeta(final MasterProcedureEnv env, final HTableDescriptor hTableDescriptor, final List<HRegionInfo> regionInfos) throws IOException { MetaTableAccessor.addRegionsToMeta(env.getMasterServices().getConnection(), regionInfos, hTableDescriptor.getRegionReplication()); }