GetTableSchemaRequest(KuduTable masterTable, String id, String name) { super(masterTable); Preconditions.checkArgument(id != null ^ name != null, "Only one of table ID or the table name should be provided"); this.id = id; this.name = name; }
public Slice(byte[] data) { Preconditions.checkNotNull(data, "array is null"); this.data = data; this.offset = 0; this.length = data.length; }
/** * Transfers this buffer's data to the specified destination starting at * the specified absolute {@code index} until the destination's position * reaches its limit. * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * if {@code index + dst.remaining()} is greater than * {@code this.capacity} */ public void getBytes(int index, ByteBuffer destination) { Preconditions.checkPositionIndex(index, this.length); index += offset; destination.put(data, index, Math.min(length, destination.remaining())); }
/** * 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; }
/** * Sets the specified byte at the specified absolute {@code index} in this * buffer. The 24 high-order bits of the specified value are ignored. * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} */ public void setByte(int index, int value) { Preconditions.checkPositionIndexes(index, index + 1, this.length); index += offset; data[index] = (byte) value; }
Preconditions.checkState(response.getStep() == NegotiateStep.TLS_HANDSHAKE); Preconditions.checkArgument(!response.getTlsHandshake().isEmpty(), "empty TLS message from server");
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 " + "from the same client that opened this KuduSession"); Preconditions.checkState(fullBuffer == null); fullBuffer = activeBuffer; activeBuffer = null;
/** * Refreshes the active buffer. This should only be called after a * {@link #flush()} when the active buffer is {@code null}, there is an * inactive buffer available (see {@link #inactiveBufferAvailable()}, and * {@link #monitor} is locked. */ @GuardedBy("monitor") private void refreshActiveBuffer() { Preconditions.checkState(activeBuffer == null); activeBuffer = inactiveBuffers.remove(); activeBuffer.reset(); }
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()); }
RangePartitionBound lowerBoundType, RangePartitionBound upperBoundType) { Preconditions.checkNotNull(lowerBound); Preconditions.checkNotNull(upperBound); Preconditions.checkArgument(lowerBound.getSchema().equals(upperBound.getSchema()));
/** * Gets a 16-bit short integer at the specified absolute {@code index} in * this slice. * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 2} is greater than {@code this.capacity} */ public short getShort(int index) { Preconditions.checkPositionIndexes(index, index + Shorts.BYTES, this.length); index += offset; return (short) ((data[index] & 0xFF) | (data[index + 1] << 8)); }
Preconditions.checkArgument(column.equals(other.column), "predicates from different columns may not be merged"); Preconditions.checkState(other.type == PredicateType.IN_LIST); return other.merge(this); return other.merge(this); } else { Preconditions.checkState(other.type == PredicateType.RANGE); byte[] newLower = other.lower == null || (lower != null && compare(column, lower, other.lower) >= 0) ? lower : other.lower; Preconditions.checkState(other.type == PredicateType.IN_LIST); List<byte[]> values = new ArrayList<>(); for (byte[] value : inListValues) {
/** Initiate opening TCP connection to the server. */ @GuardedBy("lock") private void connect() { Preconditions.checkState(lock.isHeldByCurrentThread()); Preconditions.checkState(state == State.NEW); state = State.CONNECTING; connectFuture = channel.connect(serverInfo.getResolvedAddress()); }
Preconditions.checkState(!(decoded.getFirst() instanceof Exception)); if (client.isStatisticsEnabled()) { rpc.updateStatistics(client.getStatistics(), decoded.getFirst()); Preconditions.checkNotNull(header); LOG.debug("{} unexpected exception {} while handling call: callId {}, RPC {}", connection.getLogPrefix(), e, header.getCallId(), rpc);
/** * Set the maximum number of boss threads. * Optional. * If not provided, 1 is used. */ public AsyncKuduClientBuilder bossCount(int bossCount) { Preconditions.checkArgument(bossCount > 0, "bossCount should be greater than 0"); this.bossCount = bossCount; return this; }
RangePartitionBound lowerBoundType, RangePartitionBound upperBoundType) { Preconditions.checkNotNull(lowerBound); Preconditions.checkNotNull(upperBound); Preconditions.checkArgument(lowerBound.getSchema().equals(upperBound.getSchema()));
/** * Gets a byte at the specified absolute {@code index} in this buffer. * * @throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or * {@code index + 1} is greater than {@code this.capacity} */ public byte getByte(int index) { Preconditions.checkPositionIndexes(index, index + 1, this.length); index += offset; return data[index]; }
public Slice(byte[] data, int offset, int length) { Preconditions.checkNotNull(data, "array is null"); this.data = data; this.offset = offset; this.length = length; }
public Entry get(byte[] partitionKey) { if (partitionKey == null) { // Master lookup. rwl.readLock().lock(); try { Preconditions.checkState(entries.size() <= 1); return entries.get(AsyncKuduClient.EMPTY_ARRAY); } finally { rwl.readLock().unlock(); } } Map.Entry<byte[], Entry> entry; rwl.readLock().lock(); try { entry = entries.floorEntry(partitionKey); } finally { rwl.readLock().unlock(); } if (entry == null || (entry.getValue().getUpperBoundPartitionKey().length > 0 && Bytes.memcmp(partitionKey, entry.getValue().getUpperBoundPartitionKey()) >= 0) || entry.getValue().isStale()) { return null; } return entry.getValue(); }
/** * Set the maximum number of worker threads. * Optional. * If not provided, (2 * the number of available processors) is used. If * this client instance will be used on a machine running many client * instances, it may be wise to lower this count, for example to avoid * resource limits, at the possible cost of some performance of this client * instance. */ public AsyncKuduClientBuilder workerCount(int workerCount) { Preconditions.checkArgument(workerCount > 0, "workerCount should be greater than 0"); this.workerCount = workerCount; return this; }