/** 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()); }
/** * 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(); }
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(); }
if (state == State.TERMINATED) { Preconditions.checkState(queuedMessages == null); Preconditions.checkState(inflightMessages == null); return; Preconditions.checkState(negotiationFailure != null); Preconditions.checkState(inflightMessages.isEmpty()); needNewAuthnToken = negotiationFailure.status.getCode().equals( RpcHeader.ErrorStatusPB.RpcErrorCodePB.FATAL_INVALID_AUTHENTICATION_TOKEN);
/** {@inheritDoc} */ @Override public void channelConnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) { lock.lock(); try { if (state == State.TERMINATED) { return; } Preconditions.checkState(state == State.CONNECTING); state = State.NEGOTIATING; } finally { lock.unlock(); } Channels.write(channel, ChannelBuffers.wrappedBuffer(CONNECTION_HEADER)); Negotiator negotiator = new Negotiator(serverInfo.getAndCanonicalizeHostname(), securityContext, (credentialsPolicy == CredentialsPolicy.PRIMARY_CREDENTIALS)); ctx.getPipeline().addBefore(ctx.getName(), "negotiation", negotiator); negotiator.sendHello(channel); }
Preconditions.checkState(empty == null); } finally { lock.unlock();
private void handleNegotiateResponse(Channel chan, RpcHeader.NegotiatePB response) throws IOException { Preconditions.checkState(response.getStep() == NegotiateStep.NEGOTIATE, "Expected NEGOTIATE message, got {}", response.getStep()); // Store the supported features advertised by the server. serverFeatures = getFeatureFlags(response); // If the server supports TLS, we will always speak TLS to it. final boolean negotiatedTls = serverFeatures.contains(RpcFeatureFlag.TLS); // Check the negotiated authentication type sent by the server. chosenAuthnType = chooseAuthenticationType(response); if (chosenAuthnType == AuthenticationTypePB.TypeCase.SASL) { chooseAndInitializeSaslMech(response); } // If we negotiated TLS, then we want to start the TLS handshake; otherwise, // we can move directly to the authentication phase. if (negotiatedTls) { startTlsHandshake(chan); } else { startAuthentication(chan); } }
Preconditions.checkState(columnsBitSet.get(idx), "Column %s is not set", col.getName());
private void handleSuccessResponse(Channel chan, NegotiatePB response) throws IOException { Preconditions.checkState(saslClient.isComplete(), "server sent SASL_SUCCESS step, but SASL negotiation is not complete"); if (chosenMech == SaslMechanism.GSSAPI) { if (response.hasNonce()) { // Grab the nonce from the server, if it has sent one. We'll send it back // later with SASL integrity protection as part of the connection context. nonce = response.getNonce().toByteArray(); } if (peerCert != null) { // Check the channel bindings provided by the server against the expected channel bindings. verifyChannelBindings(response); } } finish(chan); }
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()); }
try { negotiationResult = (Negotiator.Success) m; Preconditions.checkState(state == State.TERMINATED || inflightMessages.isEmpty()); Callback<Void, CallResponseInfo> empty = inflightMessages.put( qm.message.getHeaderBuilder().getCallId(), qm.cb); Preconditions.checkState(empty == null); Preconditions.checkState(state == State.NEGOTIATING); return; Preconditions.checkState(state == State.NEGOTIATING); Preconditions.checkState(inflightMessages.isEmpty()); return; Preconditions.checkState(state == State.READY); responseCbk = inflightMessages.remove(callId); } finally {
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) {
ColumnSchema column = schema.getColumnByIndex(index); Type type = column.getType(); Preconditions.checkState(isSet(index)); int offset = schema.getColumnOffset(index); switch (type) {
Preconditions.checkState(response.getStep() == NegotiateStep.TLS_HANDSHAKE); Preconditions.checkArgument(!response.getTlsHandshake().isEmpty(), "empty TLS message from server");
Preconditions.checkState(!(decoded.getFirst() instanceof Exception)); if (client.isStatisticsEnabled()) { rpc.updateStatistics(client.getStatistics(), decoded.getFirst());
Preconditions.checkState(fullBuffer == null); fullBuffer = activeBuffer; activeBuffer = null;