use of com.google.cloud.dataproc.v1.Cluster in project grpc-java by grpc.
the class LoadBalancerConfigFactoryTest method ringHash_legacy.
@Test
public void ringHash_legacy() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder().setLbPolicy(LbPolicy.RING_HASH).setRingHashLbConfig(RingHashLbConfig.newBuilder().setMinimumRingSize(UInt64Value.of(RING_HASH_MIN_RING_SIZE)).setMaximumRingSize(UInt64Value.of(RING_HASH_MAX_RING_SIZE)).setHashFunction(HashFunction.XX_HASH)).build();
assertThat(newLbConfig(cluster, true, true)).isEqualTo(VALID_RING_HASH_CONFIG);
}
use of com.google.cloud.dataproc.v1.Cluster in project grpc-java by grpc.
the class LoadBalancerConfigFactoryTest method customConfig_notEnabled.
@Test
public void customConfig_notEnabled() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder().setLoadBalancingPolicy(LoadBalancingPolicy.newBuilder().addPolicies(RING_HASH_POLICY)).build();
// Custom LB flag not set, so we use old logic that will default to round_robin.
assertThat(newLbConfig(cluster, true, false)).isEqualTo(VALID_ROUND_ROBIN_CONFIG);
}
use of com.google.cloud.dataproc.v1.Cluster in project grpc-java by grpc.
the class LoadBalancerConfigFactoryTest method customLbInWrr_providerRegistered.
// When a provider for the endpoint picking custom policy is available, the configuration should
// use it.
@Test
public void customLbInWrr_providerRegistered() throws ResourceInvalidException {
LoadBalancerRegistry.getDefaultRegistry().register(CUSTOM_POLICY_PROVIDER);
Cluster cluster = Cluster.newBuilder().setLoadBalancingPolicy(LoadBalancingPolicy.newBuilder().addPolicies(buildWrrPolicy(CUSTOM_POLICY, ROUND_ROBIN_POLICY))).build();
assertThat(newLbConfig(cluster, false, true)).isEqualTo(VALID_CUSTOM_CONFIG_IN_WRR);
}
use of com.google.cloud.dataproc.v1.Cluster in project grpc-java by grpc.
the class ClientXdsClient method handleCdsResponse.
@Override
public void handleCdsResponse(ServerInfo serverInfo, String versionInfo, List<Any> resources, String nonce) {
syncContext.throwIfNotInThisSynchronizationContext();
Map<String, ParsedResource> parsedResources = new HashMap<>(resources.size());
Set<String> unpackedResources = new HashSet<>(resources.size());
Set<String> invalidResources = new HashSet<>();
List<String> errors = new ArrayList<>();
Set<String> retainedEdsResources = new HashSet<>();
for (int i = 0; i < resources.size(); i++) {
Any resource = resources.get(i);
// Unpack the Cluster.
Cluster cluster;
try {
resource = maybeUnwrapResources(resource);
cluster = unpackCompatibleType(resource, Cluster.class, ResourceType.CDS.typeUrl(), ResourceType.CDS.typeUrlV2());
} catch (InvalidProtocolBufferException e) {
errors.add("CDS response Resource index " + i + " - can't decode Cluster: " + e);
continue;
}
if (!isResourceNameValid(cluster.getName(), resource.getTypeUrl())) {
errors.add("Unsupported resource name: " + cluster.getName() + " for type: " + ResourceType.CDS);
continue;
}
String clusterName = canonifyResourceName(cluster.getName());
// unrequested resources.
if (!cdsResourceSubscribers.containsKey(clusterName)) {
continue;
}
unpackedResources.add(clusterName);
// Process Cluster into CdsUpdate.
CdsUpdate cdsUpdate;
try {
Set<String> certProviderInstances = null;
if (getBootstrapInfo() != null && getBootstrapInfo().certProviders() != null) {
certProviderInstances = getBootstrapInfo().certProviders().keySet();
}
cdsUpdate = processCluster(cluster, retainedEdsResources, certProviderInstances, serverInfo, loadBalancerRegistry);
} catch (ResourceInvalidException e) {
errors.add("CDS response Cluster '" + clusterName + "' validation error: " + e.getMessage());
invalidResources.add(clusterName);
continue;
}
parsedResources.put(clusterName, new ParsedResource(cdsUpdate, resource));
}
logger.log(XdsLogLevel.INFO, "Received CDS Response version {0} nonce {1}. Parsed resources: {2}", versionInfo, nonce, unpackedResources);
handleResourceUpdate(serverInfo, ResourceType.CDS, parsedResources, invalidResources, retainedEdsResources, versionInfo, nonce, errors);
}
use of com.google.cloud.dataproc.v1.Cluster in project cdap by caskdata.
the class DataprocClient method getClusterImageVersion.
/**
* Get image version for the specified cluster. This information will not be present if the cluster could not be
* found, or the cluster specification doesn't contain this information
*
* @param name the cluster name
* @return the cluster image version if available.
* @throws RetryableProvisionException if there was a non 4xx error code returned
*/
Optional<String> getClusterImageVersion(String name) throws RetryableProvisionException {
Optional<Cluster> clusterOptional = getDataprocCluster(name);
if (!clusterOptional.isPresent()) {
return Optional.empty();
}
Cluster cluster = clusterOptional.get();
SoftwareConfig softwareConfig = cluster.getConfig().getSoftwareConfig();
return Optional.ofNullable(softwareConfig.getImageVersion());
}
Aggregations