/** * Checks if the exception is CallQueueTooBig exception (maybe wrapped * into some RemoteException). * @param t exception to check * @return true if it's a CQTBE, false otherwise */ public static boolean isCallQueueTooBigException(Throwable t) { t = findException(t); return (t instanceof CallQueueTooBigException); }
/** * @param pbBytes A pb serialized {@link ByteArrayComparable} instance * @return An instance of {@link ByteArrayComparable} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static ByteArrayComparable parseFrom(final byte [] pbBytes) throws DeserializationException { throw new DeserializationException( "parseFrom called on base ByteArrayComparable, but should be called on derived type"); }
public static boolean isMetaClearingException(Throwable cur) { cur = findException(cur); if (cur == null) { return true; } return !isSpecialException(cur) || (cur instanceof RegionMovedException) || cur instanceof NotServingRegionException; }
public void handleThrowable(Throwable t1, ServerName serverName, MutableBoolean couldNotCommunicateWithServer, MutableBoolean guaranteedClientSideOnly) throws IOException { Throwable t2 = ClientExceptionsUtil.translatePFFE(t1); boolean isLocalException = !(t2 instanceof RemoteException); if ((isLocalException && ClientExceptionsUtil.isConnectionException(t2))) { couldNotCommunicateWithServer.setValue(true); guaranteedClientSideOnly.setValue(!(t2 instanceof CallTimeoutException)); handleFailureToServer(serverName, t2); } }
private void cleanServerCache(ServerName server, Throwable regionException) { if (ClientExceptionsUtil.isMetaClearingException(regionException)) { // We want to make sure to clear the cache in case there were location-related exceptions. // We don't to clear the cache for every possible exception that comes through, however. asyncProcess.connection.clearCaches(server); } }
/** * Cleans the call not yet sent when we finish. */ public void cleanup(IOException e) { IOException ie = new ConnectionClosingException( "Connection to " + remoteId.address + " is closing."); for (Call call : callsToWrite) { call.setException(ie); } callsToWrite.clear(); } }
public static MethodDescriptor getMethodDescriptor(final String methodName, final ServiceDescriptor serviceDesc) throws UnknownProtocolException { Descriptors.MethodDescriptor methodDesc = serviceDesc.findMethodByName(methodName); if (methodDesc == null) { throw new UnknownProtocolException("Unknown method " + methodName + " called on service " + serviceDesc.getFullName()); } return methodDesc; }
private static void checkRegionsToMerge(MasterProcedureEnv env, final RegionInfo[] regionsToMerge, final boolean forcible) throws MergeRegionException { // For now, we only merge 2 regions. // It could be extended to more than 2 regions in the future. if (regionsToMerge == null || regionsToMerge.length != 2) { throw new MergeRegionException("Expected to merge 2 regions, got: " + Arrays.toString(regionsToMerge)); } checkRegionsToMerge(env, regionsToMerge[0], regionsToMerge[1], forcible); }
/** * Set new {@link State} but only if currently in <code>expected</code> State (if not, throw * {@link UnexpectedStateException}. */ public void transitionState(final State update, final State... expected) throws UnexpectedStateException { if (!setState(update, expected)) { throw new UnexpectedStateException("Expected " + Arrays.toString(expected) + " so could move to " + update + " but current state=" + getState()); } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!queue.isEmpty()) { queue.releaseAndFailAll(new ConnectionClosedException("Connection closed")); } ctx.close(promise); } }
/** * * Concrete implementers can signal a failure condition in their code by throwing an * {@link IOException}. * * @param pbBytes A pb serialized {@link Filter} instance * @return An instance of {@link Filter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static Filter parseFrom(final byte [] pbBytes) throws DeserializationException { throw new DeserializationException( "parseFrom called on base Filter, but should be called on derived type"); }
/** * Checks if the exception is CallDroppedException (maybe wrapped * into some RemoteException). * @param t exception to check * @return true if it's a CQTBE, false otherwise */ public static boolean isCallDroppedException(Throwable t) { t = findException(t); return (t instanceof CallDroppedException); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!queue.isEmpty()) { queue.releaseAndFailAll(new ConnectionClosedException("Connection closed")); } ctx.close(promise); } }
/** * @param bytes bytes to check * @throws DeserializationException if we are missing the pb magic prefix */ public static void expectPBMagicPrefix(final byte[] bytes) throws DeserializationException { if (!isPBMagicPrefix(bytes)) { String bytesPrefix = bytes == null ? "null" : Bytes.toStringBinary(bytes, 0, PB_MAGIC.length); throw new DeserializationException( "Missing pb magic " + Bytes.toString(PB_MAGIC) + " prefix, bytes: " + bytesPrefix); } }
protected static Throwable unwrap(Throwable t) { if (t == null) { return t; } if (t instanceof TIOError || t instanceof IOError) { t = t.getCause(); } return ClientExceptionsUtil.findException(t); } }
/** * @param bytes bytes to check * @throws DeserializationException if we are missing the pb magic prefix */ public static void expectPBMagicPrefix(final byte[] bytes) throws DeserializationException { if (!isPBMagicPrefix(bytes)) { String bytesPrefix = bytes == null ? "null" : Bytes.toStringBinary(bytes, 0, PB_MAGIC.length); throw new DeserializationException( "Missing pb magic " + Bytes.toString(PB_MAGIC) + " prefix" + ", bytes: " + bytesPrefix); } }
public static TableState parseFrom(TableName tableName, byte[] bytes) throws DeserializationException { try { return convert(tableName, HBaseProtos.TableState.parseFrom(bytes)); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } }
/** * @param pbBytes A pb serialized {@link NullComparator} instance * @return An instance of {@link NullComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static NullComparator parseFrom(final byte [] pbBytes) throws DeserializationException { try { // Just parse. Don't use what we parse since on end we are returning new NullComparator. ComparatorProtos.NullComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new NullComparator(); }
/** * @param pbBytes A pb serialized {@link SubstringComparator} instance * @return An instance of {@link SubstringComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static SubstringComparator parseFrom(final byte [] pbBytes) throws DeserializationException { ComparatorProtos.SubstringComparator proto; try { proto = ComparatorProtos.SubstringComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new SubstringComparator(proto.getSubstr()); }
/** * @param pbBytes A pb serialized {@link RandomRowFilter} instance * @return An instance of {@link RandomRowFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static RandomRowFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.RandomRowFilter proto; try { proto = FilterProtos.RandomRowFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new RandomRowFilter(proto.getChance()); }