public Slice(byte[] data) { Preconditions.checkNotNull(data, "array is null"); this.data = data; this.offset = 0; this.length = data.length; }
public Slice(byte[] data, int offset, int length) { Preconditions.checkNotNull(data, "array is null"); this.data = data; this.offset = offset; this.length = length; }
/** * Construct RpcProxy object. * * @param client top-level Kudu client object * @param connection the connection associated with the target Kudu server */ RpcProxy(AsyncKuduClient client, Connection connection) { this.client = Preconditions.checkNotNull(client); this.connection = Preconditions.checkNotNull(connection); }
public static Slice copiedBuffer(String string, Charset charset) { Preconditions.checkNotNull(string, "string is null"); Preconditions.checkNotNull(charset, "charset is null"); return wrappedBuffer(string.getBytes(charset)); }
public BufferedOperation(Deferred<LocatedTablet> tablet, Operation operation) { tabletLookup = AsyncUtil.addBoth(tablet, new Callback<Void, Object>() { @Override public Void call(final Object tablet) { BufferedOperation.this.tablet = tablet; return null; } }); this.operation = Preconditions.checkNotNull(operation); }
public static Slice copiedBuffer(ByteBuffer source, int sourceOffset, int length) { Preconditions.checkNotNull(source, "source is null"); int newPosition = source.position() + sourceOffset; return copiedBuffer((ByteBuffer) source.duplicate().order(ByteOrder.LITTLE_ENDIAN).clear() .limit(newPosition + length).position(newPosition)); }
public static Slice copiedBuffer(ByteBuffer source) { Preconditions.checkNotNull(source, "source is null"); Slice copy = allocate(source.limit() - source.position()); copy.setBytes(0, source.duplicate().order(ByteOrder.LITTLE_ENDIAN)); return copy; }
/** * Constructor for all the fields. The intent is that there should only be one ServerInfo * instance per UUID the client is connected to. * @param uuid server's UUID * @param hostPort server's hostname and port * @param resolvedAddr resolved address used to check if the server is local */ public ServerInfo(String uuid, HostAndPort hostPort, InetAddress resolvedAddr) { Preconditions.checkNotNull(uuid); Preconditions.checkArgument(hostPort.getPort() > 0); this.uuid = uuid; this.hostPort = hostPort; this.resolvedAddr = new InetSocketAddress(resolvedAddr, hostPort.getPort()); Boolean isLocal = isLocalAddressCache.get(resolvedAddr); if (isLocal == null) { isLocal = NetUtil.isLocalAddress(resolvedAddr); isLocalAddressCache.put(resolvedAddr, isLocal); } this.local = isLocal; }
private void sendTokenExchange(Channel chan) { // We must not send a token unless we have successfully finished // authenticating via TLS. Preconditions.checkNotNull(authnToken); Preconditions.checkNotNull(sslHandshakeFuture); Preconditions.checkState(sslHandshakeFuture.isSuccess()); RpcHeader.NegotiatePB.Builder builder = RpcHeader.NegotiatePB.newBuilder() .setStep(NegotiateStep.TOKEN_EXCHANGE) .setAuthnToken(authnToken); state = State.AWAIT_TOKEN_EXCHANGE; sendSaslMessage(chan, builder.build()); }
private void sendSaslMessage(Channel channel, RpcHeader.NegotiatePB msg) { Preconditions.checkNotNull(channel); RpcHeader.RequestHeader.Builder builder = RpcHeader.RequestHeader.newBuilder(); builder.setCallId(SASL_CALL_ID); Channels.write(channel, new RpcOutboundMessage(builder, msg)); }
@Nullable String tableId, @Nullable KuduRpc<?> parent) { Preconditions.checkNotNull(tableName);
@Override public Deferred<ConnectToMasterResponsePB> call(Exception result) throws Exception { if (result instanceof RpcRemoteException) { RpcRemoteException rre = (RpcRemoteException)result; if (rre.getErrPB().getCode() == RpcErrorCodePB.ERROR_INVALID_REQUEST && rre.getErrPB().getUnsupportedFeatureFlagsCount() > 0) { AsyncKuduClient.LOG.debug("Falling back to GetMasterRegistration() RPC to connect " + "to server running Kudu < 1.3."); final Deferred<ConnectToMasterResponsePB> newAttempt = Preconditions.checkNotNull(rpc.getDeferred()); rpc.setUseOldMethod(); masterProxy.sendRpc(rpc); return newAttempt; } } return Deferred.fromError(result); } });
@Override Message createRequestPB() { final GetTableSchemaRequestPB.Builder builder = GetTableSchemaRequestPB.newBuilder(); Builder identifierBuilder = TableIdentifierPB.newBuilder(); if (id != null) { identifierBuilder.setTableId(ByteString.copyFromUtf8(id)); } else { Preconditions.checkNotNull(name); identifierBuilder.setTableName(name); } builder.setTable(identifierBuilder.build()); return builder.build(); }
RangePartitionBound lowerBoundType, RangePartitionBound upperBoundType) { Preconditions.checkNotNull(lowerBound); Preconditions.checkNotNull(upperBound); Preconditions.checkArgument(lowerBound.getSchema().equals(upperBound.getSchema()));
RangePartitionBound lowerBoundType, RangePartitionBound upperBoundType) { Preconditions.checkNotNull(lowerBound); Preconditions.checkNotNull(upperBound); Preconditions.checkArgument(lowerBound.getSchema().equals(upperBound.getSchema()));
/** * Package-private access point for {@link AsyncKuduScanner}s to scan more rows. * @param scanner The scanner to use. * @return A deferred row. */ Deferred<AsyncKuduScanner.Response> scanNextRows(final AsyncKuduScanner scanner) { RemoteTablet tablet = Preconditions.checkNotNull(scanner.currentTablet()); KuduRpc<AsyncKuduScanner.Response> nextRequest = scanner.getNextRowsRequest(); // Important to increment the attempts before the next if statement since // getSleepTimeForRpc() relies on it if the client is null or dead. nextRequest.attempt++; final ServerInfo info = tablet.getReplicaSelectedServerInfo(nextRequest.getReplicaSelection()); if (info == null) { return delayedSendRpcToTablet(nextRequest, new RecoverableException(Status.RemoteError( String.format("No information on servers hosting tablet %s, will retry later", tablet.getTabletId())))); } Deferred<AsyncKuduScanner.Response> d = nextRequest.getDeferred(); RpcProxy.sendRpc(this, connectionCache.getConnection( info, Connection.CredentialsPolicy.ANY_CREDENTIALS), nextRequest); return d; }
Preconditions.checkNotNull(header); LOG.debug("{} unexpected exception {} while handling call: callId {}, RPC {}", connection.getLogPrefix(), e, header.getCallId(), rpc);
Preconditions.checkNotNull(operation, "Can not apply a null operation"); Preconditions.checkArgument(operation.getTable().getAsyncClient() == client, "Applied operations must be created from a KuduTable instance opened " +