The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
7.6 KiB

// Copyright 2016 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_TEST_CPP_END2END_CONNECTION_DELAY_INJECTOR_H
#define GRPC_TEST_CPP_END2END_CONNECTION_DELAY_INJECTOR_H
#include <memory>
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
#include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/gprpp/time.h"
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
#include "src/core/lib/iomgr/socket_utils_posix.h"
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/timer.h"
namespace grpc {
namespace testing {
// Allows injecting connection-establishment delays into C-core.
// Typical usage:
//
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
// // At grpc_init() time.
// ConnectionAttemptInjector::Init();
//
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
// // When an injection is desired.
// ConnectionDelayInjector delay_injector(grpc_core::Duration::Seconds(10));
// delay_injector.Start();
//
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
// The injection is global, so there must be only one ConnectionAttemptInjector
// object at any one time.
class ConnectionAttemptInjector {
public:
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
// Global initializer. Replaces the iomgr TCP client vtable.
// Must be called exactly once after grpc_init() but before any TCP
// connections are established.
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
static void Init();
virtual ~ConnectionAttemptInjector();
// Must be called after instantiation.
void Start();
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
// Invoked for every TCP connection attempt.
// Implementations must eventually either invoke the closure
// themselves or delegate to the iomgr implementation by calling
// AttemptConnection(). QueuedAttempt may be used to queue an attempt
// for asynchronous processing.
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
virtual void HandleConnection(
grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_event_engine::experimental::EndpointConfig& config,
const grpc_resolved_address* addr, grpc_core::Timestamp deadline) = 0;
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
protected:
// Represents a queued attempt.
// The caller must invoke either Resume() or Fail() before destroying.
class QueuedAttempt {
public:
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
QueuedAttempt(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
const grpc_event_engine::experimental::EndpointConfig& config,
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
const grpc_resolved_address* addr,
grpc_core::Timestamp deadline)
: closure_(closure),
endpoint_(ep),
interested_parties_(interested_parties),
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
config_(*reinterpret_cast<const grpc_event_engine::experimental::
ChannelArgsEndpointConfig*>(&config)),
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
deadline_(deadline) {
memcpy(&address_, addr, sizeof(address_));
}
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
~QueuedAttempt() { GPR_ASSERT(closure_ == nullptr); }
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
// Caller must invoke this from a thread with an ExecCtx.
void Resume() {
GPR_ASSERT(closure_ != nullptr);
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
AttemptConnection(closure_, endpoint_, interested_parties_, config_,
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
&address_, deadline_);
closure_ = nullptr;
}
// Caller must invoke this from a thread with an ExecCtx.
void Fail(grpc_error_handle error) {
GPR_ASSERT(closure_ != nullptr);
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure_, error);
closure_ = nullptr;
}
private:
grpc_closure* closure_;
grpc_endpoint** endpoint_;
grpc_pollset_set* interested_parties_;
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
grpc_event_engine::experimental::ChannelArgsEndpointConfig config_;
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
grpc_resolved_address address_;
grpc_core::Timestamp deadline_;
};
// Injects a delay before continuing a connection attempt.
class InjectedDelay {
public:
virtual ~InjectedDelay() = default;
InjectedDelay(grpc_core::Duration duration, grpc_closure* closure,
grpc_endpoint** ep, grpc_pollset_set* interested_parties,
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
const grpc_event_engine::experimental::EndpointConfig& config,
const grpc_resolved_address* addr,
grpc_core::Timestamp deadline);
private:
// Subclasses can override to perform an action when the attempt resumes.
virtual void BeforeResumingAction() {}
static void TimerCallback(void* arg, grpc_error_handle /*error*/);
QueuedAttempt attempt_;
grpc_timer timer_;
grpc_closure timer_callback_;
};
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
static void AttemptConnection(
grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_event_engine::experimental::EndpointConfig& config,
const grpc_resolved_address* addr, grpc_core::Timestamp deadline);
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
};
// A concrete implementation that injects a fixed delay.
class ConnectionDelayInjector : public ConnectionAttemptInjector {
public:
explicit ConnectionDelayInjector(grpc_core::Duration duration)
: duration_(duration) {}
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
void HandleConnection(
grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_event_engine::experimental::EndpointConfig& config,
const grpc_resolved_address* addr,
grpc_core::Timestamp deadline) override;
priority and ring_hash LBs: fix interactions when using ring_hash under priority (#29332) * refactor connection delay injection from client_lb_end2end_test * fix build * fix build on older compilers * clang-format * buildifier * a bit of code cleanup * start failover time whenever the child reports CONNECTING, and don't cancel when deactivating * clang-format * rewrite test * simplify logic in priority policy * clang-format * switch to using a bit to indicate child healthiness * fix reversed comment * more changes in priority and ring_hash. priority: - go back to starting failover timer upon CONNECTING, but only if seen READY or IDLE more recently than TRANSIENT_FAILURE ring_hash: - don't flap back and forth between IDLE and CONNECTING; once we go CONNECTING, we stay there until either TF or READY - after the first subchannel goes TF, we proactively start another subchannel connecting, just like we do after a second subchannel reports TF, to ensure that we don't stay in CONNECTING indefinitely if we aren't getting any new picks - always return ring hash's picker, regardless of connectivity state - update the subchannel connectivity state seen by the picker upon subchannel list creation - start proactive subchannel connection attempt upon subchannel list creation if needed * ring_hash: fix connectivity state seen by aggregation and picker * fix obiwan error * swap the order of ring_hash aggregation rules 3 and 4 * restore original test * refactor connection injector QueuedAttempt code * add test showing that ring_hash will continue connecting without picks * clang-format * don't actually need seen_failure_since_ready_ anymore * fix TSAN problem * address code review comments
3 years ago
private:
grpc_core::Duration duration_;
};
// A concrete implementation that allows injecting holds for individual
// connection attemps, one at a time.
class ConnectionHoldInjector : public ConnectionAttemptInjector {
private:
grpc_core::Mutex mu_; // Needs to be declared up front.
public:
class Hold {
public:
// Do not instantiate directly -- must be created via AddHold().
Hold(ConnectionHoldInjector* injector, int port, bool intercept_completion);
// Waits for the connection attempt to start.
// After this returns, exactly one of Resume() or Fail() must be called.
void Wait();
// Resumes a connection attempt. Must be called after Wait().
void Resume();
// Fails a connection attempt. Must be called after Wait().
void Fail(grpc_error_handle error);
// If the hold was created with intercept_completion=true, then this
// can be called after Resume() to wait for the connection attempt
// to complete.
void WaitForCompletion();
// Returns true if the connection attempt has been started.
bool IsStarted();
private:
friend class ConnectionHoldInjector;
static void OnComplete(void* arg, grpc_error_handle error);
ConnectionHoldInjector* injector_;
const int port_;
const bool intercept_completion_;
std::unique_ptr<QueuedAttempt> queued_attempt_
ABSL_GUARDED_BY(&ConnectionHoldInjector::mu_);
grpc_core::CondVar start_cv_;
grpc_closure on_complete_;
grpc_closure* original_on_complete_;
grpc_core::CondVar complete_cv_;
};
// Adds a hold for a given port. The caller may then use Wait() on
// the resulting Hold object to wait for the connection attempt to start.
// If intercept_completion is true, the caller can use WaitForCompletion()
// on the resulting Hold object.
std::unique_ptr<Hold> AddHold(int port, bool intercept_completion = false);
private:
Modifying iomgr tcp code to use event engine EndpointConfig instead of channel_args (#30028) * convert tcp code to use EndpointConfig and successfully compile * regenerate projects * copying config options used in tcp code to create map backed endpoint configs * fix minor build issues * fix includes in tests * fix some build and test issues * modifying endpoint config definition from an abstract interface into a concrete implementation * minor fix * add unreachable code check * fix some windows build issues * fix more build issues * adding a grpc_tcp_generic_options struct to hold data extracted from EndpointConfig * code formatting * simplify * fix sanity checks * fix windows issues * some posix fixes * disabling copy constructor and copy assignment operator for endpoint config * fix sanity checks * fix syntax error * fix weird formatting * fix build issue * fix review comments * reverting un-necessary change * remove channel args completely from windows impl since it is unused * remove unused headers and fix usage in endpoint_pair_windows.cc * cleanup * cleanup * fix some initialization issues * re-generate projects * removing some files * fix ifdef for windows * fixing windows build issue due to improper header file include * Automated change: Fix sanity tests * Automated change: Fix sanity tests * review comments * add comment * review comments * rename GetPointer to GetVoidPointer * cleanup * Automated change: Fix sanity tests * removing EndpointConfig::Get method * Automated change: Fix sanity tests * minor fix Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2 years ago
void HandleConnection(
grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_event_engine::experimental::EndpointConfig& config,
const grpc_resolved_address* addr,
grpc_core::Timestamp deadline) override;
std::vector<Hold*> holds_;
};
} // namespace testing
} // namespace grpc
#endif // GRPC_TEST_CPP_END2END_CONNECTION_DELAY_INJECTOR_H