Search in sources :

Example 46 with ServiceException

use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.

the class TestClientExceptionsUtil method testFindException.

@Test
public void testFindException() {
    IOException ioe = new IOException("Tesst");
    ServiceException se = new ServiceException(ioe);
    assertEquals(ioe, ClientExceptionsUtil.findException(se));
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) Test(org.junit.Test)

Example 47 with ServiceException

use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.

the class TestClientTokenUtil method testObtainToken.

@Test
public void testObtainToken() throws Exception {
    Exception injected = new Exception("injected");
    Class<?> clientTokenUtil = cl.loadClass(ClientTokenUtil.class.getCanonicalName());
    Field shouldInjectFault = clientTokenUtil.getDeclaredField("injectedException");
    shouldInjectFault.setAccessible(true);
    shouldInjectFault.set(null, new ServiceException(injected));
    try {
        ClientTokenUtil.obtainToken((Connection) null);
        fail("Should have injected exception.");
    } catch (IOException e) {
        assertException(injected, e);
    }
    CompletableFuture<?> future = ClientTokenUtil.obtainToken((AsyncConnection) null);
    try {
        future.get();
        fail("Should have injected exception.");
    } catch (ExecutionException e) {
        assertException(injected, e);
    }
    Boolean loaded = (Boolean) cl.loadClass(ProtobufUtil.class.getCanonicalName()).getDeclaredMethod("isClassLoaderLoaded").invoke(null);
    assertFalse("Should not have loaded DynamicClassLoader", loaded);
}
Also used : Field(java.lang.reflect.Field) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) Test(org.junit.Test)

Example 48 with ServiceException

use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.

the class RSRpcServices method closeRegion.

/**
 * Close a region on the region server.
 *
 * @param controller the RPC controller
 * @param request the request
 * @throws ServiceException
 */
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public CloseRegionResponse closeRegion(final RpcController controller, final CloseRegionRequest request) throws ServiceException {
    final ServerName sn = (request.hasDestinationServer() ? ProtobufUtil.toServerName(request.getDestinationServer()) : null);
    try {
        checkOpen();
        throwOnWrongStartCode(request);
        final String encodedRegionName = ProtobufUtil.getRegionEncodedName(request.getRegion());
        requestCount.increment();
        if (sn == null) {
            LOG.info("Close " + encodedRegionName + " without moving");
        } else {
            LOG.info("Close " + encodedRegionName + ", moving to " + sn);
        }
        boolean closed = server.closeRegion(encodedRegionName, false, sn);
        CloseRegionResponse.Builder builder = CloseRegionResponse.newBuilder().setClosed(closed);
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ServerName(org.apache.hadoop.hbase.ServerName) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) CloseRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) UncheckedIOException(java.io.UncheckedIOException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 49 with ServiceException

use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.

the class RSRpcServices method cleanupBulkLoad.

@Override
public CleanupBulkLoadResponse cleanupBulkLoad(RpcController controller, CleanupBulkLoadRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        HRegion region = getRegion(request.getRegion());
        server.getSecureBulkLoadManager().cleanupBulkLoad(region, request);
        return CleanupBulkLoadResponse.newBuilder().build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) UncheckedIOException(java.io.UncheckedIOException)

Example 50 with ServiceException

use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.

the class RSRpcServices method flushRegion.

/**
 * Flush a region on the region server.
 *
 * @param controller the RPC controller
 * @param request the request
 * @throws ServiceException
 */
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public FlushRegionResponse flushRegion(final RpcController controller, final FlushRegionRequest request) throws ServiceException {
    try {
        checkOpen();
        requestCount.increment();
        HRegion region = getRegion(request.getRegion());
        LOG.info("Flushing " + region.getRegionInfo().getRegionNameAsString());
        boolean shouldFlush = true;
        if (request.hasIfOlderThanTs()) {
            shouldFlush = region.getEarliestFlushTimeForAllStores() < request.getIfOlderThanTs();
        }
        FlushRegionResponse.Builder builder = FlushRegionResponse.newBuilder();
        if (shouldFlush) {
            boolean writeFlushWalMarker = request.hasWriteFlushWalMarker() ? request.getWriteFlushWalMarker() : false;
            // Go behind the curtain so we can manage writing of the flush WAL marker
            HRegion.FlushResultImpl flushResult = null;
            if (request.hasFamily()) {
                List families = new ArrayList();
                families.add(request.getFamily().toByteArray());
                flushResult = region.flushcache(families, writeFlushWalMarker, FlushLifeCycleTracker.DUMMY);
            } else {
                flushResult = region.flushcache(true, writeFlushWalMarker, FlushLifeCycleTracker.DUMMY);
            }
            boolean compactionNeeded = flushResult.isCompactionNeeded();
            if (compactionNeeded) {
                server.getCompactSplitThread().requestSystemCompaction(region, "Compaction through user triggered flush");
            }
            builder.setFlushed(flushResult.isFlushSucceeded());
            builder.setWroteFlushWalMarker(flushResult.wroteFlushWalMarker);
        }
        builder.setLastFlushTime(region.getEarliestFlushTimeForAllStores());
        return builder.build();
    } catch (DroppedSnapshotException ex) {
        // Cache flush can fail in a few places. If it fails in a critical
        // section, we get a DroppedSnapshotException and a replay of wal
        // is required. Currently the only way to do this is a restart of
        // the server.
        server.abort("Replay of WAL required. Forcing server shutdown", ex);
        throw new ServiceException(ex);
    } catch (IOException ie) {
        throw new ServiceException(ie);
    }
}
Also used : DroppedSnapshotException(org.apache.hadoop.hbase.DroppedSnapshotException) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList) FlushRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionResponse) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) UncheckedIOException(java.io.UncheckedIOException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Aggregations

ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)130 IOException (java.io.IOException)112 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)100 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)39 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)28 UncheckedIOException (java.io.UncheckedIOException)27 TableName (org.apache.hadoop.hbase.TableName)22 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)22 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)19 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)16 UnknownProtocolException (org.apache.hadoop.hbase.exceptions.UnknownProtocolException)16 Test (org.junit.Test)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ArrayList (java.util.ArrayList)15 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)15 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)15 ServerNotRunningYetException (org.apache.hadoop.hbase.ipc.ServerNotRunningYetException)15 KeeperException (org.apache.zookeeper.KeeperException)14 Table (org.apache.hadoop.hbase.client.Table)13 User (org.apache.hadoop.hbase.security.User)13