本文整理汇总了Java中org.apache.hadoop.hbase.UnknownRegionException类的典型用法代码示例。如果您正苦于以下问题:Java UnknownRegionException类的具体用法?Java UnknownRegionException怎么用?Java UnknownRegionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnknownRegionException类属于org.apache.hadoop.hbase包,在下文中一共展示了UnknownRegionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMoveThrowsUnknownRegionException
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Test
public void testMoveThrowsUnknownRegionException() throws IOException {
TableName tableName =
TableName.valueOf("testMoveThrowsUnknownRegionException");
HTableDescriptor htd = new HTableDescriptor(tableName);
HColumnDescriptor hcd = new HColumnDescriptor("value");
htd.addFamily(hcd);
admin.createTable(htd, null);
try {
HRegionInfo hri = new HRegionInfo(
tableName, Bytes.toBytes("A"), Bytes.toBytes("Z"));
admin.move(hri.getEncodedNameAsBytes(), null);
fail("Region should not be moved since it is fake");
} catch (IOException ioe) {
assertTrue(ioe instanceof UnknownRegionException);
} finally {
TEST_UTIL.deleteTable(tableName);
}
}
示例2: assign
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public void assign(final byte [] regionName)throws IOException {
checkInitialized();
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
if (cpHost != null) {
if (cpHost.preAssign(pair.getFirst())) {
return;
}
}
assignRegion(pair.getFirst());
if (cpHost != null) {
cpHost.postAssign(pair.getFirst());
}
}
示例3: unassign
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public void unassign(final byte [] regionName, final boolean force)
throws IOException {
checkInitialized();
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
HRegionInfo hri = pair.getFirst();
if (cpHost != null) {
if (cpHost.preUnassign(hri, force)) {
return;
}
}
if (force) {
this.assignmentManager.regionOffline(hri);
assignRegion(hri);
} else {
this.assignmentManager.unassign(hri, force);
}
if (cpHost != null) {
cpHost.postUnassign(hri, force);
}
}
示例4: testCloseRegionIfInvalidRegionNameIsPassed
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
final String name = this.name.getMethodName();
byte[] tableName = Bytes.toBytes(name);
createTableWithDefaultConf(tableName);
RegionInfo info = null;
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(tableName));
List<RegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
for (RegionInfo regionInfo : onlineRegions) {
if (!regionInfo.isMetaRegion()) {
if (regionInfo.getRegionNameAsString().contains(name)) {
info = regionInfo;
try {
admin.unassign(Bytes.toBytes("sample"), true);
} catch (UnknownRegionException nsre) {
// expected, ignore it
}
}
}
}
onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
assertTrue("The region should be present in online regions list.",
onlineRegions.contains(info));
}
示例5: testMoveThrowsUnknownRegionException
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Test
public void testMoveThrowsUnknownRegionException() throws IOException {
final TableName tableName = TableName.valueOf(name.getMethodName());
HTableDescriptor htd = new HTableDescriptor(tableName);
HColumnDescriptor hcd = new HColumnDescriptor("value");
htd.addFamily(hcd);
admin.createTable(htd, null);
try {
RegionInfo hri = RegionInfoBuilder.newBuilder(tableName)
.setStartKey(Bytes.toBytes("A"))
.setEndKey(Bytes.toBytes("Z"))
.build();
admin.move(hri.getEncodedNameAsBytes(), null);
fail("Region should not be moved since it is fake");
} catch (IOException ioe) {
assertTrue(ioe instanceof UnknownRegionException);
} finally {
TEST_UTIL.deleteTable(tableName);
}
}
示例6: splitRegionAsync
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint)
throws IOException {
byte[] encodedNameofRegionToSplit = HRegionInfo.isEncodedRegionName(regionName) ?
regionName : Bytes.toBytes(HRegionInfo.encodeRegionName(regionName));
Pair<RegionInfo, ServerName> pair = getRegion(regionName);
if (pair != null) {
if (pair.getFirst() != null &&
pair.getFirst().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {
throw new IllegalArgumentException ("Can't invoke split on non-default regions directly");
}
} else {
throw new UnknownRegionException (
"Can't invoke merge on unknown region "
+ Bytes.toStringBinary(encodedNameofRegionToSplit));
}
return splitRegionAsync(pair.getFirst(), splitPoint);
}
示例7: unassign
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public void unassign(final byte [] regionName, final boolean force)
throws IOException {
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
HRegionInfo hri = pair.getFirst();
if (cpHost != null) {
if (cpHost.preUnassign(hri, force)) {
return;
}
}
if (force) {
this.assignmentManager.clearRegionFromTransition(hri);
assignRegion(hri);
} else {
this.assignmentManager.unassign(hri, force);
}
if (cpHost != null) {
cpHost.postUnassign(hri, force);
}
}
示例8: move
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
/**
* Move the region <code>r</code> to <code>dest</code>.
* @param encodedRegionName The encoded region name; i.e. the hash that makes
* up the region name suffix: e.g. if regionname is
* <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
* then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
* @param destServerName The servername of the destination regionserver. If
* passed the empty byte array we'll assign to a random server. A server name
* is made of host, port and startcode. Here is an example:
* <code> host187.example.com,60020,1289493121758</code>
* @throws UnknownRegionException Thrown if we can't find a region named
* <code>encodedRegionName</code>
* @throws ZooKeeperConnectionException
* @throws MasterNotRunningException
*/
public void move(final byte [] encodedRegionName, final byte [] destServerName)
throws UnknownRegionException, MasterNotRunningException, ZooKeeperConnectionException {
MasterAdminKeepAliveConnection master = connection.getKeepAliveMasterAdmin();
try {
MoveRegionRequest request = RequestConverter.buildMoveRegionRequest(encodedRegionName, destServerName);
master.moveRegion(null,request);
} catch (ServiceException se) {
IOException ioe = ProtobufUtil.getRemoteException(se);
if (ioe instanceof UnknownRegionException) {
throw (UnknownRegionException)ioe;
}
LOG.error("Unexpected exception: " + se + " from calling HMaster.moveRegion");
} catch (DeserializationException de) {
LOG.error("Could not parse destination server name: " + de);
}
finally {
master.close();
}
}
示例9: offlineRegion
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
/**
* Special method, only used by hbck.
*/
@Override
public OfflineRegionResponse offlineRegion(RpcController controller, OfflineRegionRequest request)
throws ServiceException {
final byte [] regionName = request.getRegion().getValue().toByteArray();
RegionSpecifierType type = request.getRegion().getType();
if (type != RegionSpecifierType.REGION_NAME) {
LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
+ " actual: " + type);
}
try {
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));
HRegionInfo hri = pair.getFirst();
this.assignmentManager.regionOffline(hri);
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
return OfflineRegionResponse.newBuilder().build();
}
示例10: assignRegion
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public AssignRegionResponse assignRegion(RpcController controller,
AssignRegionRequest req) throws ServiceException {
try {
final byte [] regionName = req.getRegion().getValue().toByteArray();
RegionSpecifierType type = req.getRegion().getType();
AssignRegionResponse arr = AssignRegionResponse.newBuilder().build();
master.checkInitialized();
if (type != RegionSpecifierType.REGION_NAME) {
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
+ " actual: " + type);
}
RegionStates regionStates = master.assignmentManager.getRegionStates();
HRegionInfo regionInfo = regionStates.getRegionInfo(regionName);
if (regionInfo == null) throw new UnknownRegionException(Bytes.toString(regionName));
if (master.cpHost != null) {
if (master.cpHost.preAssign(regionInfo)) {
return arr;
}
}
LOG.info(master.getClientIdAuditPrefix()
+ " assign " + regionInfo.getRegionNameAsString());
master.assignmentManager.assign(regionInfo, true, true);
if (master.cpHost != null) {
master.cpHost.postAssign(regionInfo);
}
return arr;
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
示例11: offlineRegion
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
/**
* Offline specified region from master's in-memory state. It will not attempt to
* reassign the region as in unassign.
*
* This is a special method that should be used by experts or hbck.
*
*/
@Override
public OfflineRegionResponse offlineRegion(RpcController controller,
OfflineRegionRequest request) throws ServiceException {
final byte [] regionName = request.getRegion().getValue().toByteArray();
RegionSpecifierType type = request.getRegion().getType();
if (type != RegionSpecifierType.REGION_NAME) {
LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
+ " actual: " + type);
}
try {
master.checkInitialized();
Pair<HRegionInfo, ServerName> pair =
MetaTableAccessor.getRegion(master.getConnection(), regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));
HRegionInfo hri = pair.getFirst();
if (master.cpHost != null) {
master.cpHost.preRegionOffline(hri);
}
LOG.info(master.getClientIdAuditPrefix() + " offline " + hri.getRegionNameAsString());
master.assignmentManager.regionOffline(hri);
if (master.cpHost != null) {
master.cpHost.postRegionOffline(hri);
}
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
return OfflineRegionResponse.newBuilder().build();
}
示例12: unassignRegion
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public UnassignRegionResponse unassignRegion(RpcController controller,
UnassignRegionRequest req) throws ServiceException {
try {
final byte [] regionName = req.getRegion().getValue().toByteArray();
RegionSpecifierType type = req.getRegion().getType();
final boolean force = req.getForce();
UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();
master.checkInitialized();
if (type != RegionSpecifierType.REGION_NAME) {
LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
+ " actual: " + type);
}
Pair<HRegionInfo, ServerName> pair =
MetaTableAccessor.getRegion(master.getConnection(), regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
HRegionInfo hri = pair.getFirst();
if (master.cpHost != null) {
if (master.cpHost.preUnassign(hri, force)) {
return urr;
}
}
LOG.debug(master.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
+ " in current location if it is online and reassign.force=" + force);
master.assignmentManager.unassign(hri, force);
if (master.assignmentManager.getRegionStates().isRegionOffline(hri)) {
LOG.debug("Region " + hri.getRegionNameAsString()
+ " is not online on any region server, reassigning it.");
master.assignRegion(hri);
}
if (master.cpHost != null) {
master.cpHost.postUnassign(hri, force);
}
return urr;
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
示例13: move
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public void move(final byte[] encodedRegionName, final byte[] destServerName)
throws UnknownRegionException {
Pair<HRegionInfo, ServerName> p =
this.assignmentManager.getAssignment(encodedRegionName);
if (p == null)
throw new UnknownRegionException(Bytes.toStringBinary(encodedRegionName));
ServerName dest = null;
if (destServerName == null || destServerName.length == 0) {
LOG.info("Passed destination servername is null or empty so choosing a server at random");
List<ServerName> destServers = this.serverManager.getOnlineServersList();
destServers.remove(p.getSecond());
// If i have only one RS then destination can be null.
dest = balancer.randomAssignment(destServers);
} else {
dest = new ServerName(Bytes.toString(destServerName));
}
// Now we can do the move
RegionPlan rp = new RegionPlan(p.getFirst(), p.getSecond(), dest);
try {
checkInitialized();
if (this.cpHost != null) {
if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
return;
}
}
LOG.info("Added move plan " + rp + ", running balancer");
this.assignmentManager.balance(rp);
if (this.cpHost != null) {
this.cpHost.postMove(p.getFirst(), p.getSecond(), dest);
}
} catch (IOException ioe) {
UnknownRegionException ure = new UnknownRegionException(
Bytes.toStringBinary(encodedRegionName));
ure.initCause(ioe);
throw ure;
}
}
示例14: offline
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
/**
* Special method, only used by hbck.
*/
@Override
public void offline(final byte[] regionName) throws IOException {
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));
HRegionInfo hri = pair.getFirst();
this.assignmentManager.regionOffline(hri);
}
示例15: assignRegion
import org.apache.hadoop.hbase.UnknownRegionException; //导入依赖的package包/类
@Override
public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req)
throws ServiceException {
try {
final byte [] regionName = req.getRegion().getValue().toByteArray();
RegionSpecifierType type = req.getRegion().getType();
AssignRegionResponse arr = AssignRegionResponse.newBuilder().build();
checkInitialized();
if (type != RegionSpecifierType.REGION_NAME) {
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
+ " actual: " + type);
}
HRegionInfo regionInfo = assignmentManager.getRegionStates().getRegionInfo(regionName);
if (regionInfo == null) throw new UnknownRegionException(Bytes.toString(regionName));
if (cpHost != null) {
if (cpHost.preAssign(regionInfo)) {
return arr;
}
}
LOG.info(getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString());
assignmentManager.assign(regionInfo, true, true);
if (cpHost != null) {
cpHost.postAssign(regionInfo);
}
return arr;
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}