Java 类org.apache.hadoop.hbase.NotServingRegionException 实例源码

项目:ditb    文件:HRegionServer.java   
protected Region getRegionByEncodedName(byte[] regionName, String encodedRegionName)
    throws NotServingRegionException {
  Region region = this.onlineRegions.get(encodedRegionName);
  if (region == null) {
    MovedRegionInfo moveInfo = getMovedRegion(encodedRegionName);
    if (moveInfo != null) {
      throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum());
    }
    Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName));
    String regionNameStr =
        regionName == null ? encodedRegionName : Bytes.toStringBinary(regionName);
    if (isOpening != null && isOpening.booleanValue()) {
      throw new RegionOpeningException(
          "Region " + regionNameStr + " is opening on " + this.serverName);
    }
    throw new NotServingRegionException(
        "Region " + regionNameStr + " is not online on " + this.serverName);
  }
  return region;
}
项目:ditb    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " + t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!rpcServices.checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:ditb    文件:TestAdmin2.java   
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));
  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
            .getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:ditb    文件:TestAdmin2.java   
@Test (timeout=300000)
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));

  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName(regionInfo
            .getRegionNameAsString(), rs.getServerName().getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it.
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:ditb    文件:TestRegionServerNoMaster.java   
public static void checkRegionIsClosed(HBaseTestingUtility HTU, HRegionServer rs,
    HRegionInfo hri) throws Exception {
  while (!rs.getRegionsInTransitionInRS().isEmpty()) {
    Thread.sleep(1);
  }

  boolean exception = false;
  try {
    while ((rs.getRegion(hri.getRegionName()).isAvailable())) {
      Thread.sleep(10);
    }
  } catch (NotServingRegionException expected) {
    exception = true;
    // That's how it work: if the region is closed we have an exception.
  }
  assert(exception);
  // We don't delete the znode here, because there is not always a znode.
}
项目:LCIndex-HBase-0.94.16    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " + t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:LCIndex-HBase-0.94.16    文件:HRegionServer.java   
@QosPriority(priority = HConstants.HIGH_QOS)
protected boolean
    closeRegion(HRegionInfo region, final boolean zk, final int versionOfClosingNode)
        throws IOException {
  checkOpen();
  // Check for permissions to close.
  HRegion actualRegion = this.getFromOnlineRegions(region.getEncodedName());
  if (actualRegion != null && actualRegion.getCoprocessorHost() != null) {
    actualRegion.getCoprocessorHost().preClose(false);
  }
  LOG.info("Received close region: " + region.getRegionNameAsString()
      + ". Version of ZK closing node:" + versionOfClosingNode);
  boolean hasit = this.onlineRegions.containsKey(region.getEncodedName());
  if (!hasit) {
    LOG.warn("Received close for region we are not serving; " + region.getEncodedName());
    throw new NotServingRegionException("Received close for " + region.getRegionNameAsString()
        + " but we are not serving it");
  }
  return closeRegion(region, false, zk, versionOfClosingNode);
}
项目:pbase    文件:HRegionServer.java   
protected HRegion getRegionByEncodedName(byte[] regionName, String encodedRegionName)
        throws NotServingRegionException {
    HRegion region = this.onlineRegions.get(encodedRegionName);
    if (region == null) {
        MovedRegionInfo moveInfo = getMovedRegion(encodedRegionName);
        if (moveInfo != null) {
            throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum());
        }
        Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName));
        String regionNameStr = regionName == null ?
                encodedRegionName : Bytes.toStringBinary(regionName);
        if (isOpening != null && isOpening.booleanValue()) {
            throw new RegionOpeningException("Region " + regionNameStr +
                    " is opening on " + this.serverName);
        }
        throw new NotServingRegionException("Region " + regionNameStr +
                " is not online on " + this.serverName);
    }
    return region;
}
项目:pbase    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
    // Don't log as error if NSRE; NSRE is 'normal' operation.
    if (t instanceof NotServingRegionException) {
        LOG.debug("NotServingRegionException; " + t.getMessage());
        return t;
    }
    if (msg == null) {
        LOG.error("", RemoteExceptionHandler.checkThrowable(t));
    } else {
        LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
    }
    if (!rpcServices.checkOOME(t)) {
        checkFileSystem();
    }
    return t;
}
项目:pbase    文件:TestAdmin2.java   
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));
  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
            .getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:pbase    文件:TestAdmin2.java   
@Test (timeout=300000)
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));

  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName(regionInfo
            .getRegionNameAsString(), rs.getServerName().getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it.
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:pbase    文件:RegionServerCallable.java   
@Override
public void throwable(Throwable t, boolean retrying) {
  if (t instanceof SocketTimeoutException ||
      t instanceof ConnectException ||
      t instanceof RetriesExhaustedException ||
      (location != null && getConnection().isDeadServer(location.getServerName()))) {
    // if thrown these exceptions, we clear all the cache entries that
    // map to that slow/dead server; otherwise, let cache miss and ask
    // hbase:meta again to find the new location
    if (this.location != null) getConnection().clearCaches(location.getServerName());
  } else if (t instanceof RegionMovedException) {
    getConnection().updateCachedLocations(tableName, row, t, location);
  } else if (t instanceof NotServingRegionException && !retrying) {
    // Purge cache entries for this specific region from hbase:meta cache
    // since we don't call connect(true) when number of retries is 1.
    getConnection().deleteCachedRegionLocation(location);
  }
}
项目:HIndex    文件:HRegionServer.java   
protected HRegion getRegionByEncodedName(byte[] regionName, String encodedRegionName)
  throws NotServingRegionException {
  HRegion region = this.onlineRegions.get(encodedRegionName);
  if (region == null) {
    MovedRegionInfo moveInfo = getMovedRegion(encodedRegionName);
    if (moveInfo != null) {
      throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum());
    }
    Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName));
    String regionNameStr = regionName == null?
      encodedRegionName: Bytes.toStringBinary(regionName);
    if (isOpening != null && isOpening.booleanValue()) {
      throw new RegionOpeningException("Region " + regionNameStr + 
        " is opening on " + this.serverNameFromMasterPOV);
    }
    throw new NotServingRegionException("Region " + regionNameStr + 
      " is not online on " + this.serverNameFromMasterPOV);
  }
  return region;
}
项目:HIndex    文件:HRegionServer.java   
protected Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " + t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:HIndex    文件:TestAdmin.java   
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
            .getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:HIndex    文件:TestAdmin.java   
@Test (timeout=300000)
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName(regionInfo
            .getRegionNameAsString(), rs.getServerName().getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it.
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:HIndex    文件:RegionServerCallable.java   
@Override
public void throwable(Throwable t, boolean retrying) {
  if (t instanceof SocketTimeoutException ||
      t instanceof ConnectException ||
      t instanceof RetriesExhaustedException ||
      (location != null && getConnection().isDeadServer(location.getServerName()))) {
    // if thrown these exceptions, we clear all the cache entries that
    // map to that slow/dead server; otherwise, let cache miss and ask
    // hbase:meta again to find the new location
    if (this.location != null) getConnection().clearCaches(location.getServerName());
  } else if (t instanceof RegionMovedException) {
    getConnection().updateCachedLocations(tableName, row, t, location);
  } else if (t instanceof NotServingRegionException && !retrying) {
    // Purge cache entries for this specific region from hbase:meta cache
    // since we don't call connect(true) when number of retries is 1.
    getConnection().deleteCachedRegionLocation(location);
  }
}
项目:IRIndex    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " +  t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:IRIndex    文件:HRegionServer.java   
@QosPriority(priority=HConstants.HIGH_QOS)
protected boolean closeRegion(HRegionInfo region, final boolean zk,
  final int versionOfClosingNode)
throws IOException {
  checkOpen();
  //Check for permissions to close.
  HRegion actualRegion = this.getFromOnlineRegions(region.getEncodedName());
  if (actualRegion != null && actualRegion.getCoprocessorHost() != null) {
    actualRegion.getCoprocessorHost().preClose(false);
  }
  LOG.info("Received close region: " + region.getRegionNameAsString() +
    ". Version of ZK closing node:" + versionOfClosingNode);
  boolean hasit = this.onlineRegions.containsKey(region.getEncodedName());
  if (!hasit) {
    LOG.warn("Received close for region we are not serving; " +
      region.getEncodedName());
    throw new NotServingRegionException("Received close for "
      + region.getRegionNameAsString() + " but we are not serving it");
  }
  return closeRegion(region, false, zk, versionOfClosingNode);
}
项目:IRIndex    文件:HRegion.java   
/**
 * This method needs to be called before any public call that reads or
 * modifies stores in bulk. It has to be called just before a try.
 * #closeBulkRegionOperation needs to be called in the try's finally block
 * Acquires a writelock and checks if the region is closing or closed.
 * @throws NotServingRegionException when the region is closing or closed
 * @throws RegionTooBusyException if failed to get the lock in time
 * @throws InterruptedIOException if interrupted while waiting for a lock
 */
private void startBulkRegionOperation(boolean writeLockNeeded)
    throws NotServingRegionException, RegionTooBusyException, InterruptedIOException {
  if (this.closing.get()) {
    throw new NotServingRegionException(regionInfo.getRegionNameAsString() +
        " is closing");
  }
  if (writeLockNeeded) lock(lock.writeLock());
  else lock(lock.readLock());
  if (this.closed.get()) {
    if (writeLockNeeded) lock.writeLock().unlock();
    else lock.readLock().unlock();
    throw new NotServingRegionException(regionInfo.getRegionNameAsString() +
        " is closed");
  }
}
项目:hbase    文件:HRegionServer.java   
protected HRegion getRegionByEncodedName(byte[] regionName, String encodedRegionName)
  throws NotServingRegionException {
  HRegion region = this.onlineRegions.get(encodedRegionName);
  if (region == null) {
    MovedRegionInfo moveInfo = getMovedRegion(encodedRegionName);
    if (moveInfo != null) {
      throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum());
    }
    Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName));
    String regionNameStr = regionName == null?
      encodedRegionName: Bytes.toStringBinary(regionName);
    if (isOpening != null && isOpening.booleanValue()) {
      throw new RegionOpeningException("Region " + regionNameStr +
        " is opening on " + this.serverName);
    }
    throw new NotServingRegionException("" + regionNameStr +
      " is not online on " + this.serverName);
  }
  return region;
}
项目:hbase    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " + t.getMessage());
    return t;
  }
  Throwable e = t instanceof RemoteException ? ((RemoteException) t).unwrapRemoteException() : t;
  if (msg == null) {
    LOG.error("", e);
  } else {
    LOG.error(msg, e);
  }
  if (!rpcServices.checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:hbase    文件:TestAssignmentManager.java   
@Override
protected CloseRegionResponse execCloseRegion(ServerName server, byte[] regionName)
    throws IOException {
  switch (this.invocations++) {
  case 0: throw new NotServingRegionException("Fake");
  case 1: throw new RegionServerAbortedException("Fake!");
  case 2: throw new RegionServerStoppedException("Fake!");
  case 3: throw new ServerNotRunningYetException("Fake!");
  case 4:
    LOG.info("Return null response from serverName=" + server + "; means STUCK...TODO timeout");
    executor.schedule(new Runnable() {
      @Override
      public void run() {
        LOG.info("Sending in CRASH of " + server);
        doCrash(server);
      }
    }, 1, TimeUnit.SECONDS);
    return null;
  default:
    return super.execCloseRegion(server, regionName);
  }
}
项目:RStore    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " +  t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:RStore    文件:HRegionServer.java   
@QosPriority(priority=HIGH_QOS)
protected boolean closeRegion(HRegionInfo region, final boolean zk,
  final int versionOfClosingNode)
throws IOException {
  checkOpen();
  LOG.info("Received close region: " + region.getRegionNameAsString() +
    ". Version of ZK closing node:" + versionOfClosingNode);
  boolean hasit = this.onlineRegions.containsKey(region.getEncodedName());
  if (!hasit) {
    LOG.warn("Received close for region we are not serving; " +
      region.getEncodedName());
    throw new NotServingRegionException("Received close for "
      + region.getRegionNameAsString() + " but we are not serving it");
  }
  checkIfRegionInTransition(region, CLOSE);
  return closeRegion(region, false, zk, versionOfClosingNode);
}
项目:RStore    文件:HRegion.java   
/**
 * This method needs to be called before any public call that reads or
 * modifies stores in bulk. It has to be called just before a try.
 * #closeBulkRegionOperation needs to be called in the try's finally block
 * Acquires a writelock and checks if the region is closing or closed.
 * @throws NotServingRegionException when the region is closing or closed
 */
private void startBulkRegionOperation(boolean writeLockNeeded)
throws NotServingRegionException {
  if (this.closing.get()) {
    throw new NotServingRegionException(regionInfo.getRegionNameAsString() +
        " is closing");
  }
  if (writeLockNeeded) lock.writeLock().lock();
  else lock.readLock().lock();
  if (this.closed.get()) {
    if (writeLockNeeded) lock.writeLock().unlock();
    else lock.readLock().unlock();
    throw new NotServingRegionException(regionInfo.getRegionNameAsString() +
        " is closed");
  }
}
项目:PyroDB    文件:HRegionServer.java   
protected HRegion getRegionByEncodedName(byte[] regionName, String encodedRegionName)
  throws NotServingRegionException {
  HRegion region = this.onlineRegions.get(encodedRegionName);
  if (region == null) {
    MovedRegionInfo moveInfo = getMovedRegion(encodedRegionName);
    if (moveInfo != null) {
      throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum());
    }
    Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName));
    String regionNameStr = regionName == null?
      encodedRegionName: Bytes.toStringBinary(regionName);
    if (isOpening != null && isOpening.booleanValue()) {
      throw new RegionOpeningException("Region " + regionNameStr + 
        " is opening on " + this.serverName);
    }
    throw new NotServingRegionException("Region " + regionNameStr + 
      " is not online on " + this.serverName);
  }
  return region;
}
项目:PyroDB    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " + t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!rpcServices.checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:PyroDB    文件:TestAdmin.java   
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
            .getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:PyroDB    文件:TestAdmin.java   
@Test (timeout=300000)
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName(regionInfo
            .getRegionNameAsString(), rs.getServerName().getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it.
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:PyroDB    文件:RegionServerCallable.java   
@Override
public void throwable(Throwable t, boolean retrying) {
  if (t instanceof SocketTimeoutException ||
      t instanceof ConnectException ||
      t instanceof RetriesExhaustedException ||
      (location != null && getConnection().isDeadServer(location.getServerName()))) {
    // if thrown these exceptions, we clear all the cache entries that
    // map to that slow/dead server; otherwise, let cache miss and ask
    // hbase:meta again to find the new location
    if (this.location != null) getConnection().clearCaches(location.getServerName());
  } else if (t instanceof RegionMovedException) {
    getConnection().updateCachedLocations(tableName, row, t, location.getServerName());
  } else if (t instanceof NotServingRegionException && !retrying) {
    // Purge cache entries for this specific region from hbase:meta cache
    // since we don't call connect(true) when number of retries is 1.
    getConnection().deleteCachedRegionLocation(location);
  }
}
项目:c5    文件:HRegionServer.java   
protected HRegion getRegionByEncodedName(byte[] regionName, String encodedRegionName)
  throws NotServingRegionException {
  HRegion region = this.onlineRegions.get(encodedRegionName);
  if (region == null) {
    MovedRegionInfo moveInfo = getMovedRegion(encodedRegionName);
    if (moveInfo != null) {
      throw new RegionMovedException(moveInfo.getServerName(), moveInfo.getSeqNum());
    }
    Boolean isOpening = this.regionsInTransitionInRS.get(Bytes.toBytes(encodedRegionName));
    String regionNameStr = regionName == null?
      encodedRegionName: Bytes.toStringBinary(regionName);
    if (isOpening != null && isOpening.booleanValue()) {
      throw new RegionOpeningException("Region " + regionNameStr + " is opening");
    }
    throw new NotServingRegionException("Region " + regionNameStr + " is not online");
  }
  return region;
}
项目:c5    文件:HRegionServer.java   
protected Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " + t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:c5    文件:TestAdmin.java   
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
            .getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:c5    文件:TestAdmin.java   
@Test (timeout=300000)
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);

  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName(regionInfo
            .getRegionNameAsString(), rs.getServerName().getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it.
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs);
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
项目:c5    文件:RegionServerCallable.java   
@Override
public void throwable(Throwable t, boolean retrying) {
  if (t instanceof SocketTimeoutException ||
      t instanceof ConnectException ||
      t instanceof RetriesExhaustedException ||
      (location != null && getConnection().isDeadServer(location.getServerName()))) {
    // if thrown these exceptions, we clear all the cache entries that
    // map to that slow/dead server; otherwise, let cache miss and ask
    // hbase:meta again to find the new location
    if (this.location != null) getConnection().clearCaches(location.getServerName());
  } else if (t instanceof RegionMovedException) {
    getConnection().updateCachedLocations(tableName, row, t, location);
  } else if (t instanceof NotServingRegionException && !retrying) {
    // Purge cache entries for this specific region from hbase:meta cache
    // since we don't call connect(true) when number of retries is 1.
    getConnection().deleteCachedRegionLocation(location);
  }
}
项目:async-hbase-client    文件:AsyncRegionServerCallable.java   
@Override
public void throwable(Throwable t, boolean retrying) {
  if (t instanceof SocketTimeoutException ||
      t instanceof ConnectException ||
      t instanceof RetriesExhaustedException ||
      (location != null && getConnection().isDeadServer(location.getServerName()))) {
    // if thrown these exceptions, we clear all the cache entries that
    // map to that slow/dead server; otherwise, let cache miss and ask
    // hbase:meta again to find the new location
    if (this.location != null)
      getConnection().clearCaches(location.getServerName());
  } else if (t instanceof RegionMovedException) {
    getConnection().updateCachedLocations(tableName, row, t, location);
  } else if (t instanceof NotServingRegionException && !retrying) {
    // Purge cache entries for this specific region from hbase:meta cache
    // since we don't call connect(true) when number of retries is 1.
    getConnection().deleteCachedRegionLocation(location);
  }
}
项目:HBase-Research    文件:HRegionServer.java   
private Throwable cleanup(final Throwable t, final String msg) {
  // Don't log as error if NSRE; NSRE is 'normal' operation.
  if (t instanceof NotServingRegionException) {
    LOG.debug("NotServingRegionException; " +  t.getMessage());
    return t;
  }
  if (msg == null) {
    LOG.error("", RemoteExceptionHandler.checkThrowable(t));
  } else {
    LOG.error(msg, RemoteExceptionHandler.checkThrowable(t));
  }
  if (!checkOOME(t)) {
    checkFileSystem();
  }
  return t;
}
项目:HBase-Research    文件:HRegionServer.java   
@QosPriority(priority=HConstants.HIGH_QOS)
protected boolean closeRegion(HRegionInfo region, final boolean zk,
  final int versionOfClosingNode)
throws IOException {
  checkOpen();
  //Check for permissions to close.
  HRegion actualRegion = this.getFromOnlineRegions(region.getEncodedName());
  if (actualRegion != null && actualRegion.getCoprocessorHost() != null) {
    actualRegion.getCoprocessorHost().preClose(false);
  }
  LOG.info("Received close region: " + region.getRegionNameAsString() +
    ". Version of ZK closing node:" + versionOfClosingNode);
  boolean hasit = this.onlineRegions.containsKey(region.getEncodedName());
  if (!hasit) {
    LOG.warn("Received close for region we are not serving; " +
      region.getEncodedName());
    throw new NotServingRegionException("Received close for "
      + region.getRegionNameAsString() + " but we are not serving it");
  }
  return closeRegion(region, false, zk, versionOfClosingNode);
}
项目:HBase-Research    文件:HRegion.java   
/**
 * This method needs to be called before any public call that reads or
 * modifies stores in bulk. It has to be called just before a try.
 * #closeBulkRegionOperation needs to be called in the try's finally block
 * Acquires a writelock and checks if the region is closing or closed.
 * @throws NotServingRegionException when the region is closing or closed
 * @throws RegionTooBusyException if failed to get the lock in time
 * @throws InterruptedIOException if interrupted while waiting for a lock
 */
private void startBulkRegionOperation(boolean writeLockNeeded)
    throws NotServingRegionException, RegionTooBusyException, InterruptedIOException {
  if (this.closing.get()) {
    throw new NotServingRegionException(regionInfo.getRegionNameAsString() +
        " is closing");
  }
  if (writeLockNeeded) lock(lock.writeLock());
  else lock(lock.readLock());
  if (this.closed.get()) {
    if (writeLockNeeded) lock.writeLock().unlock();
    else lock.readLock().unlock();
    throw new NotServingRegionException(regionInfo.getRegionNameAsString() +
        " is closed");
  }
}