org.apache.hadoop.hbase.NotServingRegionException Java Examples

The following examples show how to use org.apache.hadoop.hbase.NotServingRegionException. 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: BulkWriteChannelInvoker.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
private boolean clearCacheIfNeeded(Throwable e) throws IOException{
    if (e==null ||
            e instanceof WrongPartitionException ||
            e instanceof NotServingRegionException ||
            e instanceof NotServingPartitionException ||
            e instanceof ConnectException ||
            e instanceof ConnectionClosingException ||
            e instanceof NoServerForRegionException ||
        isFailedServerException(e)) {
        /*
         * We sent it to the wrong place, so we need to resubmit it. But since we
         * pulled it from the cache, we first invalidate that cache
         */
        partitionInfoCache.invalidate(this.tableName);
        partitionInfoCache.invalidateAdapter(this.tableName);
        return true;
 }
    return false;
}
 
Example #2
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void batchMutate(List<DataMutation> mutations) throws IOException{
    try{
        Mutation[] ms = new Mutation[mutations.size()];
        int i = 0;
        for (DataMutation dm : mutations) {
            if(dm instanceof HPut)
                ms[i++] = ((HPut)dm).unwrapDelegate();
            else
                ms[i++] = ((HDelete)dm).unwrapDelegate();
        }
        region.batchMutate(ms);
    }catch(NotServingRegionException | ConnectionClosingException nsre){
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    }
}
 
Example #3
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public DataResult getLatest(byte[] rowKey,byte[] family,DataResult previous) throws IOException{
    Get g=new Get(rowKey);
    g.setMaxVersions(1);
    g.addFamily(family);

    try{
        Result result=region.get(g);
        if(previous==null)
            previous=new HResult(result);
        else{
            ((HResult)previous).set(result);
        }
        return previous;
    }catch(NotServingRegionException| ConnectionClosingException nsre){
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    }
}
 
Example #4
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public DataResult getLatest(byte[] key,DataResult previous) throws IOException{
    Get g=new Get(key);
    g.setMaxVersions(1);

    try{
        Result result=region.get(g);
        if(previous==null)
            previous=new HResult(result);
        else{
            ((HResult)previous).set(result);
        }
        return previous;
    }catch(NotServingRegionException | ConnectionClosingException | AssertionError | NullPointerException nsre){
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    }
}
 
Example #5
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public DataResult getFkCounter(byte[] key,DataResult previous) throws IOException{
    Get g=new Get(key);
    g.addColumn(SIConstants.DEFAULT_FAMILY_BYTES,SIConstants.FK_COUNTER_COLUMN_BYTES);

    try{
        Result r=region.get(g);
        if(previous==null)
            previous=new HResult(r);
        else{
            ((HResult)previous).set(r);
        }
        return previous;
    }catch(NotServingRegionException | ConnectionClosingException nsre){
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    }
}
 
Example #6
Source File: HRegionServer.java    From hbase with Apache License 2.0 6 votes vote down vote up
private 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) {
      throw new RegionOpeningException("Region " + regionNameStr +
        " is opening on " + this.serverName);
    }
    throw new NotServingRegionException("" + regionNameStr +
      " is not online on " + this.serverName);
  }
  return region;
}
 
Example #7
Source File: HRegionServer.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Cleanup after Throwable caught invoking method. Converts <code>t</code> to
 * IOE if it isn't already.
 *
 * @param t Throwable
 * @param msg Message to log in error. Can be null.
 * @return Throwable converted to an IOE; methods can only let out IOEs.
 */
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;
}
 
Example #8
Source File: TestMetaCache.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Throw some exceptions. Mostly throw exceptions which do not clear meta cache.
 * Periodically throw NotSevingRegionException which clears the meta cache.
 * @throws ServiceException
 */
private void throwSomeExceptions(FakeRSRpcServices rpcServices,
                                 HBaseProtos.RegionSpecifier regionSpec)
    throws ServiceException {
  if (!isTestTable(rpcServices, regionSpec)) {
    return;
  }

  numReqs++;
  // Succeed every 5 request, throw cache clearing exceptions twice every 5 requests and throw
  // meta cache preserving exceptions otherwise.
  if (numReqs % 5 ==0) {
    return;
  } else if (numReqs % 5 == 1 || numReqs % 5 == 2) {
    throw new ServiceException(new NotServingRegionException());
  }
  // Round robin between different special exceptions.
  // This is not ideal since exception types are not tied to the operation performed here,
  // But, we don't really care here if we throw MultiActionTooLargeException while doing
  // single Gets.
  expCount++;
  Throwable t = metaCachePreservingExceptions.get(
      expCount % metaCachePreservingExceptions.size());
  throw new ServiceException(t);
}
 
Example #9
Source File: BaseScannerRegionObserver.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * Wrapper for {@link #postScannerOpen(ObserverContext, Scan, RegionScanner)} that ensures no non IOException is thrown,
 * to prevent the coprocessor from becoming blacklisted.
 *
 */
@Override
public final RegionScanner postScannerOpen(
        final ObserverContext<RegionCoprocessorEnvironment> c, final Scan scan,
        final RegionScanner s) throws IOException {
   try {
        if (!isRegionObserverFor(scan)) {
            return s;
        }
        return new RegionScannerHolder(c, scan, s);
    } catch (Throwable t) {
        // If the exception is NotServingRegionException then throw it as
        // StaleRegionBoundaryCacheException to handle it by phoenix client other wise hbase
        // client may recreate scans with wrong region boundaries.
        if(t instanceof NotServingRegionException) {
            Exception cause = new StaleRegionBoundaryCacheException(c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString());
            throw new DoNotRetryIOException(cause.getMessage(), cause);
        }
        ServerUtil.throwIOException(c.getEnvironment().getRegion().getRegionInfo().getRegionNameAsString(), t);
        return null; // impossible
    }
}
 
Example #10
Source File: ServerUtil.java    From phoenix with Apache License 2.0 5 votes vote down vote up
public static SQLException parseServerExceptionOrNull(Throwable t) {
    while (t.getCause() != null) {
        if (t instanceof NotServingRegionException) {
            return parseRemoteException(new StaleRegionBoundaryCacheException());
        }
        t = t.getCause();
    }
    return parseRemoteException(t);
}
 
Example #11
Source File: TestTableInputFormat.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Create a table that throws a DoNoRetryIOException on first scanner next
 * call
 *
 * @throws IOException
 */
static Table createDNRIOEScannerTable(byte[] name, final int failCnt)
    throws IOException {
  // build up a mock scanner stuff to fail the first time
  Answer<ResultScanner> a = new Answer<ResultScanner>() {
    int cnt = 0;

    @Override
    public ResultScanner answer(InvocationOnMock invocation) throws Throwable {
      // first invocation return the busted mock scanner
      if (cnt++ < failCnt) {
        // create mock ResultScanner that always fails.
        Scan scan = mock(Scan.class);
        doReturn(Bytes.toBytes("bogus")).when(scan).getStartRow(); // avoid npe
        ResultScanner scanner = mock(ResultScanner.class);

        invocation.callRealMethod(); // simulate NotServingRegionException
        doThrow(
            new NotServingRegionException("Injected simulated TimeoutException"))
            .when(scanner).next();
        return scanner;
      }

      // otherwise return the real scanner.
      return (ResultScanner) invocation.callRealMethod();
    }
  };

  Table htable = spy(createTable(name));
  doAnswer(a).when(htable).getScanner((Scan) anyObject());
  return htable;
}
 
Example #12
Source File: TestTableInputFormat.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Create a table that throws a NotServingRegionException on first scanner
 * next call
 *
 * @throws IOException
 */
static Table createDNRIOEScannerTable(byte[] name, final int failCnt)
    throws IOException {
  // build up a mock scanner stuff to fail the first time
  Answer<ResultScanner> a = new Answer<ResultScanner>() {
    int cnt = 0;

    @Override
    public ResultScanner answer(InvocationOnMock invocation) throws Throwable {
      // first invocation return the busted mock scanner
      if (cnt++ < failCnt) {
        // create mock ResultScanner that always fails.
        Scan scan = mock(Scan.class);
        doReturn(Bytes.toBytes("bogus")).when(scan).getStartRow(); // avoid npe
        ResultScanner scanner = mock(ResultScanner.class);

        invocation.callRealMethod(); // simulate NotServingRegionException
        doThrow(
            new NotServingRegionException("Injected simulated TimeoutException"))
            .when(scanner).next();
        return scanner;
      }

      // otherwise return the real scanner.
      return (ResultScanner) invocation.callRealMethod();
    }
  };

  Table htable = spy(createTable(name));
  doAnswer(a).when(htable).getScanner((Scan) anyObject());
  return htable;
}
 
Example #13
Source File: TestTableInputFormat.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Run test assuming NotServingRegionException using newer mapreduce api
 *
 * @throws InterruptedException
 * @throws org.apache.hadoop.hbase.NotServingRegionException
 */
@Test(expected = org.apache.hadoop.hbase.NotServingRegionException.class)
public void testTableRecordReaderScannerTimeoutMapreduceTwice()
    throws IOException, InterruptedException {
  Table htable = createDNRIOEScannerTable(Bytes.toBytes("table5-mr"), 2);
  runTestMapreduce(htable);
}
 
Example #14
Source File: ClientExceptionsUtil.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static boolean isMetaClearingException(Throwable cur) {
  cur = findException(cur);

  if (cur == null) {
    return true;
  }
  return !isSpecialException(cur) || (cur instanceof RegionMovedException)
      || cur instanceof NotServingRegionException;
}
 
Example #15
Source File: ClientExceptionsUtil.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static boolean isSpecialException(Throwable cur) {
  return (cur instanceof RegionMovedException || cur instanceof RegionOpeningException
      || cur instanceof RegionTooBusyException || cur instanceof RpcThrottlingException
      || cur instanceof MultiActionResultTooLarge || cur instanceof RetryImmediatelyException
      || cur instanceof CallQueueTooBigException || cur instanceof CallDroppedException
      || cur instanceof NotServingRegionException || cur instanceof RequestTooBigException);
}
 
Example #16
Source File: ServerUtil.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * Return the first SQLException in the exception chain, otherwise parse it.
 * When we're receiving an exception locally, there's no need to string parse,
 * as the SQLException will already be part of the chain.
 * @param t
 * @return the SQLException, or null if none found
 */
public static SQLException parseLocalOrRemoteServerException(Throwable t) {
    while (t.getCause() != null) {
        if (t instanceof NotServingRegionException) {
            return parseRemoteException(new StaleRegionBoundaryCacheException());
        } else if (t instanceof SQLException) {
            return (SQLException) t;
        }
        t = t.getCause();
    }
    return parseRemoteException(t);
}
 
Example #17
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void mc(boolean tableLevel, Set<byte[]> targets) throws InterruptedException, IOException {
    int i = 1;
    for (byte[] tableOrRegion : targets) {
        if (args.has(Args.OPTION_CF)) {
            String cf = (String) args.valueOf(Args.OPTION_CF);
            try {
                System.out.print(i++ + "/" + targets.size() + " - Major compaction on " + cf + " CF of " +
                    (tableLevel ? "table " : "region ") + Bytes.toStringBinary(tableOrRegion) +
                    (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
                if (!Util.askProceedInteractively(args, true)) continue;
                admin.majorCompact(tableOrRegion, cf.getBytes());
                mcCounter.getAndIncrement();
            } catch (IOException e) {
                String message = "column family " + cf + " does not exist";
                if (e.getMessage().contains(message)) {
                    System.out.println("WARNING - " + message + " on " + Bytes.toStringBinary(tableOrRegion));
                } else {
                    throw e;
                }
            }
        } else {
            System.out.print(i++ + "/" + targets.size() + " - Major compaction on "
                + (tableLevel ? "table " : "region ")
                + Bytes.toStringBinary(tableOrRegion) + (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
            if (!Util.askProceedInteractively(args, true)) continue;
            try {
                admin.majorCompact(tableOrRegion);
            } catch (NotServingRegionException ignore) {
            }
            mcCounter.getAndIncrement();
        }
    }
}
 
Example #18
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Iterator<DataResult> batchGet(Attributable attributes,List<byte[]> rowKeys) throws IOException{
    List<Result> results=new ArrayList<>(rowKeys.size());
    try{
        for(byte[] rk : rowKeys){
            Get g=new Get(rk);
            if(attributes!=null){
                for(Map.Entry<String, byte[]> attrEntry : attributes.allAttributes().entrySet()){
                    g.setAttribute(attrEntry.getKey(),attrEntry.getValue());
                }
            }
            results.add(region.get(g));
        }
    }catch(NotServingRegionException | ConnectionClosingException nsre){
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    }
    final HResult result=new HResult();
    return Iterators.transform(results.iterator(),new Function<Result, DataResult>(){
        @Override
        public DataResult apply(Result input){
            result.set(input);
            return result;
        }
    });
}
 
Example #19
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Iterator<MutationStatus> writeBatch(DataPut[] toWrite) throws IOException{
    if(toWrite==null || toWrite.length<=0) return Collections.emptyIterator();
    Mutation[] mutations=new Mutation[toWrite.length];

    for(int i=0;i<toWrite.length;i++){
        mutations[i]=((HMutation)toWrite[i]).unwrapHbaseMutation();
    }
    try{
        OperationStatus[] operationStatuses=region.batchMutate(mutations);
        final HMutationStatus resultStatus=new HMutationStatus();
        return Iterators.transform(Iterators.forArray(operationStatuses),new Function<OperationStatus, MutationStatus>(){
            @Override
            public MutationStatus apply(OperationStatus input){
                resultStatus.set(input);
                return resultStatus;
            }
        });
    }catch(NotServingRegionException | ConnectionClosingException nsre){
        //convert HBase NSRE to Partition-level
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    } catch(NullPointerException npe) {
        // Not Setup yet during split
        throw new HRegionTooBusy(npe.getMessage());
    }
}
 
Example #20
Source File: RegionPartition.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void mutate(DataMutation put) throws IOException{
    try{
        if(put instanceof HPut)
            region.put(((HPut)put).unwrapDelegate());
        else
            region.delete(((HDelete)put).unwrapDelegate());
    }catch(NotServingRegionException | ConnectionClosingException nsre){
        throw new HNotServingRegion(nsre.getMessage());
    }catch(WrongRegionException wre){
        throw new HWrongRegion(wre.getMessage());
    }
}
 
Example #21
Source File: TransactionalRegionServer.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
/**
 * We want to delay the close region for a bit if we have commit pending
 * transactions.
 * 
 * @throws NotServingRegionException
 */
@Override
protected boolean closeRegion(final HRegionInfo region,
		final boolean abort, final boolean zk) {
	try {
		getTransactionalRegion(region.getRegionName()).prepareToClose();
	} catch (NotServingRegionException e) {
		LOG.warn(
				"Failed to wait for uncommitted transactions to commit during region close.",
				e);
	}
	return super.closeRegion(region, abort, zk);
}
 
Example #22
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void mc(boolean tableLevel, Set<byte[]> targets) throws InterruptedException, IOException {
    int i = 1;
    for (byte[] tableOrRegion : targets) {
        if (args.has(Args.OPTION_CF)) {
            String cf = (String) args.valueOf(Args.OPTION_CF);
            try {
                System.out.print(i++ + "/" + targets.size() + " - Major compaction on " + cf + " CF of " +
                    (tableLevel ? "table " : "region ") + Bytes.toStringBinary(tableOrRegion) +
                    (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
                if (!Util.askProceedInteractively(args, true)) continue;
                admin.majorCompact(tableOrRegion, cf.getBytes());
                mcCounter.getAndIncrement();
            } catch (IOException e) {
                String message = "column family " + cf + " does not exist";
                if (e.getMessage().contains(message)) {
                    System.out.println("WARNING - " + message + " on " + Bytes.toStringBinary(tableOrRegion));
                } else {
                    throw e;
                }
            }
        } else {
            System.out.print(i++ + "/" + targets.size() + " - Major compaction on "
                + (tableLevel ? "table " : "region ")
                + Bytes.toStringBinary(tableOrRegion) + (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
            if (!Util.askProceedInteractively(args, true)) continue;
            try {
                admin.majorCompact(tableOrRegion);
            } catch (NotServingRegionException ignore) {
            }
            mcCounter.getAndIncrement();
        }
    }
}
 
Example #23
Source File: TestAssignmentManagerBase.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
protected CloseRegionResponse execCloseRegion(ServerName server, byte[] regionName)
    throws IOException {
  switch (this.invocations++) {
    case 0:
      throw new NotServingRegionException("Fake");
    case 1:
      executor.schedule(new Runnable() {
        @Override
        public void run() {
          LOG.info("Sending in CRASH of " + server);
          doCrash(server);
        }
      }, 1, TimeUnit.SECONDS);
      throw new RegionServerAbortedException("Fake!");
    case 2:
      executor.schedule(new Runnable() {
        @Override
        public void run() {
          LOG.info("Sending in CRASH of " + server);
          doCrash(server);
        }
      }, 1, TimeUnit.SECONDS);
      throw new RegionServerStoppedException("Fake!");
    case 3:
      throw new ServerNotRunningYetException("Fake!");
    case 4:
      LOG.info("Returned null from serverName={}; means STUCK...TODO timeout", server);
      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);
  }
}
 
Example #24
Source File: TestReplicasClient.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void checkRegionIsClosed(String encodedRegionName) throws Exception {

    while (!getRS().getRegionsInTransitionInRS().isEmpty()) {
      Thread.sleep(1);
    }

    try {
      Assert.assertFalse(getRS().getRegionByEncodedName(encodedRegionName).isAvailable());
    } catch (NotServingRegionException expected) {
      // That's how it work: if the region is closed we have an exception.
    }

    // We don't delete the znode here, because there is not always a znode.
  }
 
Example #25
Source File: TestAsyncNonMetaRegionLocator.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void testConcurrentUpdateCachedLocationOnError() throws Exception {
  createSingleRegionTable();
  HRegionLocation loc =
      getDefaultRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT, false)
          .get();
  IntStream.range(0, 100).parallel()
      .forEach(i -> LOCATOR.updateCachedLocationOnError(loc, new NotServingRegionException()));
}
 
Example #26
Source File: TestAsyncNonMetaRegionLocator.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegionMove() throws IOException, InterruptedException, ExecutionException {
  createSingleRegionTable();
  ServerName serverName = TEST_UTIL.getRSForFirstRegionInTable(TABLE_NAME).getServerName();
  HRegionLocation loc =
    getDefaultRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT, false).get();
  assertLocEquals(EMPTY_START_ROW, EMPTY_END_ROW, serverName, loc);
  ServerName newServerName = TEST_UTIL.getHBaseCluster().getRegionServerThreads().stream()
    .map(t -> t.getRegionServer().getServerName()).filter(sn -> !sn.equals(serverName)).findAny()
    .get();

  TEST_UTIL.getAdmin().move(Bytes.toBytes(loc.getRegion().getEncodedName()), newServerName);
  while (!TEST_UTIL.getRSForFirstRegionInTable(TABLE_NAME).getServerName()
    .equals(newServerName)) {
    Thread.sleep(100);
  }
  // Should be same as it is in cache
  assertSame(loc,
    getDefaultRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT, false).get());
  LOCATOR.updateCachedLocationOnError(loc, null);
  // null error will not trigger a cache cleanup
  assertSame(loc,
    getDefaultRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT, false).get());
  LOCATOR.updateCachedLocationOnError(loc, new NotServingRegionException());
  assertLocEquals(EMPTY_START_ROW, EMPTY_END_ROW, newServerName,
    getDefaultRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT, false).get());
}
 
Example #27
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void mc(boolean tableLevel, Set<byte[]> targets) throws InterruptedException, IOException {
    int i = 1;
    for (byte[] tableOrRegion : targets) {
        if (args.has(Args.OPTION_CF)) {
            String cf = (String) args.valueOf(Args.OPTION_CF);
            try {
                System.out.print(i++ + "/" + targets.size() + " - Major compaction on " + cf + " CF of " +
                    (tableLevel ? "table " : "region ") + Bytes.toStringBinary(tableOrRegion) +
                    (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
                if (!Util.askProceedInteractively(args, true)) continue;
                admin.majorCompact(tableOrRegion, cf.getBytes());
                mcCounter.getAndIncrement();
            } catch (IOException e) {
                String message = "column family " + cf + " does not exist";
                if (e.getMessage().contains(message)) {
                    System.out.println("WARNING - " + message + " on " + Bytes.toStringBinary(tableOrRegion));
                } else {
                    throw e;
                }
            }
        } else {
            System.out.print(i++ + "/" + targets.size() + " - Major compaction on "
                + (tableLevel ? "table " : "region ")
                + Bytes.toStringBinary(tableOrRegion) + (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
            if (!Util.askProceedInteractively(args, true)) continue;
            try {
                admin.majorCompact(tableOrRegion);
            } catch (NotServingRegionException ignore) {
            }
            mcCounter.getAndIncrement();
        }
    }
}
 
Example #28
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void mc(boolean tableLevel, Set<byte[]> targets) throws InterruptedException, IOException {
    int i = 1;
    for (byte[] tableOrRegion : targets) {
        if (args.has(Args.OPTION_CF)) {
            String cf = (String) args.valueOf(Args.OPTION_CF);
            try {
                System.out.print(i++ + "/" + targets.size() + " - Major compaction on " + cf + " CF of " +
                    (tableLevel ? "table " : "region ") + Bytes.toStringBinary(tableOrRegion) +
                    (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
                if (!Util.askProceedInteractively(args, true)) continue;
                admin.majorCompact(tableOrRegion, cf.getBytes());
                mcCounter.getAndIncrement();
            } catch (IOException e) {
                String message = "column family " + cf + " does not exist";
                if (e.getMessage().contains(message)) {
                    System.out.println("WARNING - " + message + " on " + Bytes.toStringBinary(tableOrRegion));
                } else {
                    throw e;
                }
            }
        } else {
            System.out.print(i++ + "/" + targets.size() + " - Major compaction on "
                + (tableLevel ? "table " : "region ")
                + Bytes.toStringBinary(tableOrRegion) + (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
            if (!Util.askProceedInteractively(args, true)) continue;
            try {
                admin.majorCompact(tableOrRegion);
            } catch (NotServingRegionException ignore) {
            }
            mcCounter.getAndIncrement();
        }
    }
}
 
Example #29
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void mc(boolean tableLevel, Set<byte[]> targets) throws InterruptedException, IOException {
    int i = 1;
    for (byte[] tableOrRegion : targets) {
        if (args.has(Args.OPTION_CF)) {
            String cf = (String) args.valueOf(Args.OPTION_CF);
            try {
                System.out.print(i++ + "/" + targets.size() + " - Major compaction on " + cf + " CF of " +
                    (tableLevel ? "table " : "region ") + Bytes.toStringBinary(tableOrRegion) +
                    (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
                if (!Util.askProceedInteractively(args, true)) continue;
                admin.majorCompact(tableOrRegion, cf.getBytes());
                mcCounter.getAndIncrement();
            } catch (IOException e) {
                String message = "column family " + cf + " does not exist";
                if (e.getMessage().contains(message)) {
                    System.out.println("WARNING - " + message + " on " + Bytes.toStringBinary(tableOrRegion));
                } else {
                    throw e;
                }
            }
        } else {
            System.out.print(i++ + "/" + targets.size() + " - Major compaction on "
                + (tableLevel ? "table " : "region ")
                + Bytes.toStringBinary(tableOrRegion) + (tableLevel ? "" : " - " + getRegionInfo(tableOrRegion)));
            if (!Util.askProceedInteractively(args, true)) continue;
            try {
                admin.majorCompact(tableOrRegion);
            } catch (NotServingRegionException ignore) {
            }
            mcCounter.getAndIncrement();
        }
    }
}
 
Example #30
Source File: MetricsHBaseServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
public void exception(Throwable throwable) {
  source.exception();

  /**
   * Keep some metrics for commonly seen exceptions
   *
   * Try and  put the most common types first.
   * Place child types before the parent type that they extend.
   *
   * If this gets much larger we might have to go to a hashmap
   */
  if (throwable != null) {
    if (throwable instanceof OutOfOrderScannerNextException) {
      source.outOfOrderException();
    } else if (throwable instanceof RegionTooBusyException) {
      source.tooBusyException();
    } else if (throwable instanceof UnknownScannerException) {
      source.unknownScannerException();
    } else if (throwable instanceof ScannerResetException) {
      source.scannerResetException();
    } else if (throwable instanceof RegionMovedException) {
      source.movedRegionException();
    } else if (throwable instanceof NotServingRegionException) {
      source.notServingRegionException();
    } else if (throwable instanceof FailedSanityCheckException) {
      source.failedSanityException();
    } else if (throwable instanceof MultiActionResultTooLarge) {
      source.multiActionTooLargeException();
    } else if (throwable instanceof CallQueueTooBigException) {
      source.callQueueTooBigException();
    }
  }
}