public SerialReplicationChecker(Configuration conf, ReplicationSource source) { this.peerId = source.getPeerId(); this.storage = source.getQueueStorage(); this.conn = source.getServer().getConnection(); this.waitTimeMs = conf.getLong(REPLICATION_SERIALLY_WAITING_KEY, REPLICATION_SERIALLY_WAITING_DEFAULT); }
@Before public void setUp() throws IOException { ReplicationSource source = mock(ReplicationSource.class); when(source.getPeerId()).thenReturn(PEER_ID); when(source.getQueueStorage()).thenReturn(QUEUE_STORAGE); conn = mock(Connection.class); when(conn.isClosed()).thenReturn(false); doAnswer(new Answer<Table>() { @Override public Table answer(InvocationOnMock invocation) throws Throwable { return UTIL.getConnection().getTable((TableName) invocation.getArgument(0)); } }).when(conn).getTable(any(TableName.class)); Server server = mock(Server.class); when(server.getConnection()).thenReturn(conn); when(source.getServer()).thenReturn(server); checker = new SerialReplicationChecker(UTIL.getConfiguration(), source); tableName = TableName.valueOf(name.getMethodName()); }
} else { regionsAndLocations = MetaTableAccessor.getTableRegionsAndLocations( server.getConnection(), snapshotTable, false);
/** * 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); } }
void splitRegion(HRegionInfo p, HRegionInfo a, HRegionInfo b, ServerName sn, int regionReplication) throws IOException { MetaTableAccessor.splitRegion(server.getConnection(), p, a, b, sn, regionReplication); }
void mergeRegions(HRegionInfo p, HRegionInfo a, HRegionInfo b, ServerName sn, int regionReplication) throws IOException { MetaTableAccessor.mergeRegions(server.getConnection(), p, a, b, sn, regionReplication, EnvironmentEdgeManager.currentTime()); } }
@Override protected void addRegionsToMeta(final List<HRegionInfo> regionInfos, int regionReplication) throws IOException { super.addRegionsToMeta(regionInfos, regionReplication); metaChanges.updateMetaParentRegions(this.server.getConnection(), regionInfos); }
CatalogJanitor(final Server server, final MasterServices services) { super("CatalogJanitor-" + server.getServerName().toShortString(), server, server .getConfiguration().getInt("hbase.catalogjanitor.interval", 300000)); this.server = server; this.services = services; this.connection = server.getConnection(); }
/** * This method does an RPC to hbase:meta. Do not call this method with a lock/synchronize held. * @param hris The hris to check if empty in hbase:meta and if so, clean them up. */ private void cleanIfNoMetaEntry(Set<HRegionInfo> hris) { if (hris.isEmpty()) return; for (HRegionInfo hri: hris) { try { // This is RPC to meta table. It is done while we have a synchronize on // regionstates. No progress will be made if meta is not available at this time. // This is a cleanup task. Not critical. if (MetaTableAccessor.getRegion(server.getConnection(), hri.getEncodedNameAsBytes()) == null) { regionOffline(hri); FSUtils.deleteRegionDir(server.getConfiguration(), hri); } } catch (IOException e) { LOG.warn("Got exception while deleting " + hri + " directories from file system.", e); } } }
@Before public void setUp() throws IOException { ReplicationSource source = mock(ReplicationSource.class); when(source.getPeerId()).thenReturn(PEER_ID); when(source.getQueueStorage()).thenReturn(QUEUE_STORAGE); conn = mock(Connection.class); when(conn.isClosed()).thenReturn(false); doAnswer(new Answer<Table>() { @Override public Table answer(InvocationOnMock invocation) throws Throwable { return UTIL.getConnection().getTable((TableName) invocation.getArgument(0)); } }).when(conn).getTable(any(TableName.class)); Server server = mock(Server.class); when(server.getConnection()).thenReturn(conn); when(source.getServer()).thenReturn(server); checker = new SerialReplicationChecker(UTIL.getConfiguration(), source); tableName = TableName.valueOf(name.getMethodName()); }
} else { tableRegionsAndLocations = MetaTableAccessor.getTableRegionsAndLocations( server.getZooKeeper(), server.getConnection(), tableName, true);
try { TableName tableName = this.hTableDescriptor.getTableName(); if (MetaTableAccessor.tableExists(this.server.getConnection(), tableName)) { throw new TableExistsException(tableName);
MetaTableAccessor.mergeRegions(server.getConnection(), mergedRegion.getRegionInfo(), region_a.getRegionInfo(), region_b.getRegionInfo(), server.getServerName(), region_a.getTableDesc().getRegionReplication(), masterSystemTime); } else { mergeRegionsAndPutMetaEntries(server.getConnection(), mergedRegion.getRegionInfo(), region_a.getRegionInfo(), region_b.getRegionInfo(), server.getServerName(), metaEntries, region_a.getTableDesc().getRegionReplication());
/** * Get the HRegionInfo from cache, if not there, from the hbase:meta table * @param regionName * @return HRegionInfo for the region */ @SuppressWarnings("deprecation") protected HRegionInfo getRegionInfo(final byte [] regionName) { String encodedName = HRegionInfo.encodeRegionName(regionName); RegionState regionState = getRegionState(encodedName); if (regionState != null) { return regionState.getRegion(); } try { Pair<HRegionInfo, ServerName> p = MetaTableAccessor.getRegion(server.getConnection(), regionName); HRegionInfo hri = p == null ? null : p.getFirst(); if (hri != null) { createRegionState(hri); } return hri; } catch (IOException e) { server.abort("Aborting because error occoured while reading " + Bytes.toStringBinary(regionName) + " from hbase:meta", e); return null; } }
try { if (!MetaTableAccessor.tableExists(this.server.getConnection(), tableName)) { throw new TableNotFoundException(tableName);
try { if (!MetaTableAccessor.tableExists(this.server.getConnection(), tableName)) {
} else { regionsAndLocations = MetaTableAccessor.getTableRegionsAndLocations( server.getZooKeeper(), server.getConnection(), snapshotTable, false);
} else { hris = MetaTableAccessor.getTableRegions(server.getZooKeeper(), server.getConnection(), tableName);
hTableDescriptor.getRegionReplication()); metaChanges.updateMetaParentRegions(this.server.getConnection(), hris);
HFileArchiver.archiveRegion(this.services.getConfiguration(), fs, regionA); HFileArchiver.archiveRegion(this.services.getConfiguration(), fs, regionB); MetaTableAccessor.deleteMergeQualifiers(server.getConnection(), mergedRegion); return true;