-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xds: add EdsLoadBalancerProvider to shortcut CDS to EDS flow skipping…
… fallback The `EdsLoadBalancerProvider` provides `LookasideLb` (Will rename `LookasideLb` to `EdsLoadBalancer` in future, but kept the name now to show better diff) with no-op callbacks for fallback. - `CdsLoadBalancer` will load `EdsLoadBalancerProvider/LookasideLb` directly skipping fallback. - The EDS-only flow is unchanged, still loading `XdsLoadBalancerProvider/XdsLoadBalancer2`, keeping current fallback behavior and producing horrible error message when both the primary and fallback policy fail.
- Loading branch information
1 parent
4ad3acb
commit f04c492
Showing
6 changed files
with
117 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
xds/src/main/java/io/grpc/xds/EdsLoadBalancerProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2020 The 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. | ||
*/ | ||
|
||
package io.grpc.xds; | ||
|
||
import io.grpc.Internal; | ||
import io.grpc.LoadBalancer; | ||
import io.grpc.LoadBalancer.Helper; | ||
import io.grpc.LoadBalancerProvider; | ||
import io.grpc.LoadBalancerRegistry; | ||
import io.grpc.NameResolver.ConfigOrError; | ||
import io.grpc.xds.LookasideLb.EndpointUpdateCallback; | ||
import java.util.Map; | ||
|
||
/** | ||
* The provider for the "eds" balancing policy. This class should not be directly referenced in | ||
* code. The policy should be accessed through {@link io.grpc.LoadBalancerRegistry#getProvider} | ||
* with the name "eds_experimental"). | ||
*/ | ||
@Internal | ||
public class EdsLoadBalancerProvider extends LoadBalancerProvider { | ||
|
||
static final String EDS_POLICY_NAME = "eds_experimental"; | ||
|
||
@Override | ||
public boolean isAvailable() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getPriority() { | ||
return 5; | ||
} | ||
|
||
@Override | ||
public String getPolicyName() { | ||
return EDS_POLICY_NAME; | ||
} | ||
|
||
@Override | ||
public LoadBalancer newLoadBalancer(Helper helper) { | ||
return new LookasideLb( | ||
helper, | ||
new EndpointUpdateCallback() { | ||
@Override | ||
public void onWorking() {} | ||
|
||
@Override | ||
public void onError() {} | ||
|
||
@Override | ||
public void onAllDrop() {} | ||
}); | ||
} | ||
|
||
@Override | ||
public ConfigOrError parseLoadBalancingPolicyConfig( | ||
Map<String, ?> rawLoadBalancingPolicyConfig) { | ||
return XdsLoadBalancerProvider.parseLoadBalancingConfigPolicy( | ||
rawLoadBalancingPolicyConfig, LoadBalancerRegistry.getDefaultRegistry()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
xds/src/main/resources/META-INF/services/io.grpc.LoadBalancerProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
io.grpc.xds.CdsLoadBalancerProvider | ||
io.grpc.xds.EdsLoadBalancerProvider | ||
io.grpc.xds.XdsLoadBalancerProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters