Java Code Examples for org.apache.hadoop.hbase.client.RegionInfo#getRegionNameAsString()
The following examples show how to use
org.apache.hadoop.hbase.client.RegionInfo#getRegionNameAsString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MasterFileSystem.java From hbase with Apache License 2.0 | 6 votes |
public void deleteFamilyFromFS(Path rootDir, RegionInfo region, byte[] familyName) throws IOException { // archive family store files Path tableDir = CommonFSUtils.getTableDir(rootDir, region.getTable()); HFileArchiver.archiveFamily(fs, conf, region, tableDir, familyName); // delete the family folder Path familyDir = new Path(tableDir, new Path(region.getEncodedName(), Bytes.toString(familyName))); if (fs.delete(familyDir, true) == false) { if (fs.exists(familyDir)) { throw new IOException("Could not delete family " + Bytes.toString(familyName) + " from FileSystem for region " + region.getRegionNameAsString() + "(" + region.getEncodedName() + ")"); } } }
Example 2
Source File: HFileArchiver.java From hbase with Apache License 2.0 | 6 votes |
/** * Archive the store file * @param fs the filesystem where the store files live * @param regionInfo region hosting the store files * @param conf {@link Configuration} to examine to determine the archive directory * @param tableDir {@link Path} to where the table is being stored (for building the archive path) * @param family the family hosting the store files * @param storeFile file to be archived * @throws IOException if the files could not be correctly disposed. */ public static void archiveStoreFile(Configuration conf, FileSystem fs, RegionInfo regionInfo, Path tableDir, byte[] family, Path storeFile) throws IOException { Path storeArchiveDir = HFileArchiveUtil.getStoreArchivePath(conf, regionInfo, tableDir, family); // make sure we don't archive if we can't and that the archive dir exists if (!fs.mkdirs(storeArchiveDir)) { throw new IOException("Could not make archive directory (" + storeArchiveDir + ") for store:" + Bytes.toString(family) + ", deleting compacted files instead."); } // do the actual archive long start = EnvironmentEdgeManager.currentTime(); File file = new FileablePath(fs, storeFile); if (!resolveAndArchiveFile(storeArchiveDir, file, Long.toString(start))) { throw new IOException("Failed to archive/delete the file for region:" + regionInfo.getRegionNameAsString() + ", family:" + Bytes.toString(family) + " into " + storeArchiveDir + ". Something is probably awry on the filesystem."); } }
Example 3
Source File: AbstractFSWAL.java From hbase with Apache License 2.0 | 6 votes |
protected final long stampSequenceIdAndPublishToRingBuffer(RegionInfo hri, WALKeyImpl key, WALEdit edits, boolean inMemstore, RingBuffer<RingBufferTruck> ringBuffer) throws IOException { if (this.closed) { throw new IOException( "Cannot append; log is closed, regionName = " + hri.getRegionNameAsString()); } MutableLong txidHolder = new MutableLong(); MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin(() -> { txidHolder.setValue(ringBuffer.next()); }); long txid = txidHolder.longValue(); ServerCall<?> rpcCall = RpcServer.getCurrentCall().filter(c -> c instanceof ServerCall) .filter(c -> c.getCellScanner() != null).map(c -> (ServerCall) c).orElse(null); try (TraceScope scope = TraceUtil.createTrace(implClassName + ".append")) { FSWALEntry entry = new FSWALEntry(txid, key, edits, hri, inMemstore, rpcCall); entry.stampRegionSequenceId(we); ringBuffer.get(txid).load(entry); } finally { ringBuffer.publish(txid); } return txid; }
Example 4
Source File: TestAssignmentManagerBase.java From hbase with Apache License 2.0 | 6 votes |
@Override protected RegionOpeningState execOpenRegion(ServerName server, RegionOpenInfo openReq) throws IOException { RegionInfo hri = ProtobufUtil.toRegionInfo(openReq.getRegion()); long previousOpenSeqNum = am.getRegionStates().getOrCreateRegionStateNode(hri).getOpenSeqNum(); sendTransitionReport(server, openReq.getRegion(), TransitionCode.OPENED, previousOpenSeqNum + 2); // Concurrency? // Now update the state of our cluster in regionsToRegionServers. SortedSet<byte[]> regions = regionsToRegionServers.get(server); if (regions == null) { regions = new ConcurrentSkipListSet<byte[]>(Bytes.BYTES_COMPARATOR); regionsToRegionServers.put(server, regions); } if (regions.contains(hri.getRegionName())) { throw new UnsupportedOperationException(hri.getRegionNameAsString()); } regions.add(hri.getRegionName()); return RegionOpeningState.OPENED; }
Example 5
Source File: AssignmentManager.java From hbase with Apache License 2.0 | 5 votes |
private void updateRegionSplitTransition(final ServerName serverName, final TransitionCode state, final RegionInfo parent, final RegionInfo hriA, final RegionInfo hriB) throws IOException { checkMetaLoaded(parent); if (state != TransitionCode.READY_TO_SPLIT) { throw new UnexpectedStateException("unsupported split regionState=" + state + " for parent region " + parent + " maybe an old RS (< 2.0) had the operation in progress"); } // sanity check on the request if (!Bytes.equals(hriA.getEndKey(), hriB.getStartKey())) { throw new UnsupportedOperationException( "unsupported split request with bad keys: parent=" + parent + " hriA=" + hriA + " hriB=" + hriB); } if (!master.isSplitOrMergeEnabled(MasterSwitchType.SPLIT)) { LOG.warn("Split switch is off! skip split of " + parent); throw new DoNotRetryIOException("Split region " + parent.getRegionNameAsString() + " failed due to split switch off"); } // Submit the Split procedure final byte[] splitKey = hriB.getStartKey(); if (LOG.isDebugEnabled()) { LOG.debug("Split request from " + serverName + ", parent=" + parent + " splitKey=" + Bytes.toStringBinary(splitKey)); } master.getMasterProcedureExecutor().submitProcedure(createSplitProcedure(parent, splitKey)); // If the RS is < 2.0 throw an exception to abort the operation, we are handling the split if (master.getServerManager().getVersionNumber(serverName) < 0x0200000) { throw new UnsupportedOperationException(String.format( "Split handled by the master: parent=%s hriA=%s hriB=%s", parent.getShortNameToLog(), hriA, hriB)); } }
Example 6
Source File: HMaster.java From hbase with Apache License 2.0 | 5 votes |
@Override public long splitRegion(final RegionInfo regionInfo, final byte[] splitRow, final long nonceGroup, final long nonce) throws IOException { checkInitialized(); if (!isSplitOrMergeEnabled(MasterSwitchType.SPLIT)) { LOG.warn("Split switch is off! skip split of " + regionInfo); throw new DoNotRetryIOException("Split region " + regionInfo.getRegionNameAsString() + " failed due to split switch off"); } return MasterProcedureUtil.submitProcedure( new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) { @Override protected void run() throws IOException { getMaster().getMasterCoprocessorHost().preSplitRegion(regionInfo.getTable(), splitRow); LOG.info(getClientIdAuditPrefix() + " split " + regionInfo.getRegionNameAsString()); // Execute the operation asynchronously submitProcedure(getAssignmentManager().createSplitProcedure(regionInfo, splitRow)); } @Override protected String getDescription() { return "SplitTableProcedure"; } }); }
Example 7
Source File: TestHbckChore.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testForDisabledTable() throws Exception { TableName tableName = TableName.valueOf("testForDisabledTable"); RegionInfo hri = createRegionInfo(tableName, 1); String regionName = hri.getRegionNameAsString(); rsDispatcher.setMockRsExecutor(new GoodRsExecutor()); Future<byte[]> future = submitProcedure(createAssignProcedure(hri)); waitOnFuture(future); List<ServerName> serverNames = master.getServerManager().getOnlineServersList(); assertEquals(NSERVERS, serverNames.size()); hbckChore.choreForTesting(); Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = hbckChore.getInconsistentRegions(); assertTrue(inconsistentRegions.containsKey(regionName)); Pair<ServerName, List<ServerName>> pair = inconsistentRegions.get(regionName); ServerName locationInMeta = pair.getFirst(); List<ServerName> reportedRegionServers = pair.getSecond(); assertTrue(serverNames.contains(locationInMeta)); assertEquals(0, reportedRegionServers.size()); // Set table state to disabled, then not in inconsistent regions. TableStateManager tableStateManager = master.getTableStateManager(); Mockito.when(tableStateManager.isTableState(tableName, TableState.State.DISABLED)). thenReturn(true); hbckChore.choreForTesting(); inconsistentRegions = hbckChore.getInconsistentRegions(); assertFalse(inconsistentRegions.containsKey(regionName)); }
Example 8
Source File: TestHbckChore.java From hbase with Apache License 2.0 | 4 votes |
@Test public void testForUserTable() throws Exception { TableName tableName = TableName.valueOf("testForUserTable"); RegionInfo hri = createRegionInfo(tableName, 1); String regionName = hri.getRegionNameAsString(); rsDispatcher.setMockRsExecutor(new GoodRsExecutor()); Future<byte[]> future = submitProcedure(createAssignProcedure(hri)); waitOnFuture(future); List<ServerName> serverNames = master.getServerManager().getOnlineServersList(); assertEquals(NSERVERS, serverNames.size()); // Test for case1: Master thought this region opened, but no regionserver reported it. hbckChore.choreForTesting(); Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions = hbckChore.getInconsistentRegions(); assertTrue(inconsistentRegions.containsKey(regionName)); Pair<ServerName, List<ServerName>> pair = inconsistentRegions.get(regionName); ServerName locationInMeta = pair.getFirst(); List<ServerName> reportedRegionServers = pair.getSecond(); assertTrue(serverNames.contains(locationInMeta)); assertEquals(0, reportedRegionServers.size()); // Test for case2: Master thought this region opened on Server1, but regionserver reported // Server2 final ServerName tempLocationInMeta = locationInMeta; final ServerName anotherServer = serverNames.stream().filter(s -> !s.equals(tempLocationInMeta)).findFirst().get(); am.reportOnlineRegions(anotherServer, Collections.singleton(hri.getRegionName())); hbckChore.choreForTesting(); inconsistentRegions = hbckChore.getInconsistentRegions(); assertTrue(inconsistentRegions.containsKey(regionName)); pair = inconsistentRegions.get(regionName); locationInMeta = pair.getFirst(); reportedRegionServers = pair.getSecond(); assertEquals(1, reportedRegionServers.size()); assertFalse(reportedRegionServers.contains(locationInMeta)); assertTrue(reportedRegionServers.contains(anotherServer)); // Test for case3: More than one regionservers reported opened this region. am.reportOnlineRegions(locationInMeta, Collections.singleton(hri.getRegionName())); hbckChore.choreForTesting(); inconsistentRegions = hbckChore.getInconsistentRegions(); assertTrue(inconsistentRegions.containsKey(regionName)); pair = inconsistentRegions.get(regionName); locationInMeta = pair.getFirst(); reportedRegionServers = pair.getSecond(); assertEquals(2, reportedRegionServers.size()); assertTrue(reportedRegionServers.contains(locationInMeta)); assertTrue(reportedRegionServers.contains(anotherServer)); // Reported right region location, then not in inconsistent regions. am.reportOnlineRegions(anotherServer, Collections.emptySet()); hbckChore.choreForTesting(); inconsistentRegions = hbckChore.getInconsistentRegions(); assertFalse(inconsistentRegions.containsKey(regionName)); }