Search in sources :

Example 16 with Cluster

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);
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 17 with Cluster

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);
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 18 with Cluster

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);
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 19 with Cluster

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);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Any(com.google.protobuf.Any) LbEndpoint(io.grpc.xds.Endpoints.LbEndpoint) HashSet(java.util.HashSet)

Example 20 with Cluster

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());
}
Also used : Cluster(com.google.cloud.dataproc.v1.Cluster) SoftwareConfig(com.google.cloud.dataproc.v1.SoftwareConfig)

Aggregations

Test (org.junit.Test)57 Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)25 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)19 AbstractMessage (com.google.protobuf.AbstractMessage)19 ExecutionException (java.util.concurrent.ExecutionException)19 Cluster (com.google.cloud.dataproc.v1.Cluster)18 HashMap (java.util.HashMap)17 Cluster (com.google.bigtable.admin.v2.Cluster)16 ByteString (com.google.protobuf.ByteString)14 ArrayList (java.util.ArrayList)14 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)13 Cluster (com.google.container.v1.Cluster)12 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)11 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)11 Operation (com.google.longrunning.Operation)10 SoftwareConfig (com.google.cloud.dataproc.v1.SoftwareConfig)9 GceClusterConfig (com.google.cloud.dataproc.v1.GceClusterConfig)8 InstanceGroupConfig (com.google.cloud.dataproc.v1.InstanceGroupConfig)8 RetryableProvisionException (io.cdap.cdap.runtime.spi.provisioner.RetryableProvisionException)8 IOException (java.io.IOException)8