Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2019 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.internal;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import io.grpc.MethodDescriptor;
import io.grpc.internal.RetriableStream.Throttle;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
* {@link ManagedChannelServiceConfig} is a fully parsed and validated representation of service
* configuration data.
*/
final class ManagedChannelServiceConfig {
private final Map serviceMethodMap;
private final Map serviceMap;
// TODO(notcarl/zdapeng): use retryThrottling here
@Nullable
@SuppressWarnings("unused")
private final Throttle retryThrottling;
@Nullable
private final Object loadBalancingConfig;
ManagedChannelServiceConfig(
Map serviceMethodMap,
Map serviceMap,
@Nullable Throttle retryThrottling,
@Nullable Object loadBalancingConfig) {
this.serviceMethodMap = Collections.unmodifiableMap(new HashMap<>(serviceMethodMap));
this.serviceMap = Collections.unmodifiableMap(new HashMap<>(serviceMap));
this.retryThrottling = retryThrottling;
this.loadBalancingConfig = loadBalancingConfig;
}
/**
* Parses the Channel level config values (e.g. excludes load balancing)
*/
static ManagedChannelServiceConfig fromServiceConfig(
Map serviceConfig,
boolean retryEnabled,
int maxRetryAttemptsLimit,
int maxHedgedAttemptsLimit,
@Nullable Object loadBalancingConfig) {
Throttle retryThrottling = null;
if (retryEnabled) {
retryThrottling = ServiceConfigUtil.getThrottlePolicy(serviceConfig);
}
Map serviceMethodMap = new HashMap<>();
Map serviceMap = new HashMap<>();
// Try and do as much validation here before we swap out the existing configuration. In case
// the input is invalid, we don't want to lose the existing configuration.
List