-
Notifications
You must be signed in to change notification settings - Fork 32
[CASSANALYTICS-181] - Support Sidecar behind a load balancer for time… #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,29 @@ public class CassandraClusterInfoGroup implements ClusterInfo, MultiClusterSuppo | |
| */ | ||
| public static CassandraClusterInfoGroup fromBulkSparkConf(BulkSparkConf conf) | ||
| { | ||
| return fromBulkSparkConf(conf, clusterId -> new CassandraClusterInfo(conf, clusterId)); | ||
| return fromBulkSparkConf(conf, clusterId -> createClusterInfo(conf, clusterId)); | ||
| } | ||
|
|
||
| /** | ||
| * Selects the {@link CassandraClusterInfo} concrete type based on the | ||
| * {@link BulkSparkConf#sidecarBehindLoadBalancer} flag. Kept centralized so the | ||
| * driver-side factory and the executor-side broadcast reconstruction stay in lockstep. | ||
| */ | ||
| private static CassandraClusterInfo createClusterInfo(BulkSparkConf conf, String clusterId) | ||
| { | ||
| if (conf.sidecarBehindLoadBalancer) | ||
| { | ||
| LOGGER.info("Using CoordinatedCassandraClusterInfo for load-balanced Sidecar. clusterId={}", clusterId); | ||
| return new CoordinatedCassandraClusterInfo(conf, clusterId); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name CoordinatedCassandraClusterInfo is misleading. For the reader, this naming sounds like Coordinated work is happening only when sidecarBehindLoadBalancer is true, and else case below doing non-coordinated work. Need to pick appropriate name instead of CoordinatedCassandraClusterInfo |
||
| } | ||
| return new CassandraClusterInfo(conf, clusterId); | ||
| } | ||
|
|
||
| private static CassandraClusterInfo createClusterInfo(BroadcastableClusterInfo bci) | ||
| { | ||
| return bci.getConf().sidecarBehindLoadBalancer | ||
| ? new CoordinatedCassandraClusterInfo(bci) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| : new CassandraClusterInfo(bci); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -170,7 +192,7 @@ private CassandraClusterInfoGroup(BroadcastableClusterInfoGroup broadcastable) | |
| // Build list of ClusterInfo from broadcastable data | ||
| List<ClusterInfo> clusterInfosList = new ArrayList<>(); | ||
| broadcastable.forEach((clusterId, broadcastableInfo) -> { | ||
| clusterInfosList.add(new CassandraClusterInfo((BroadcastableClusterInfo) broadcastableInfo)); | ||
| clusterInfosList.add(createClusterInfo((BroadcastableClusterInfo) broadcastableInfo)); | ||
| }); | ||
| this.clusterInfos = Collections.unmodifiableList(clusterInfosList); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.cassandra.spark.bulkwriter.cloudstorage.coordinated; | ||
|
|
||
| import java.math.BigInteger; | ||
| import java.util.concurrent.CompletableFuture; | ||
|
|
||
| import com.google.common.collect.Range; | ||
|
|
||
| import o.a.c.sidecar.client.shaded.common.response.TimeSkewResponse; | ||
| import org.apache.cassandra.spark.bulkwriter.BroadcastableClusterInfo; | ||
| import org.apache.cassandra.spark.bulkwriter.BulkSparkConf; | ||
| import org.apache.cassandra.spark.bulkwriter.CassandraClusterInfo; | ||
|
|
||
| /** | ||
| * Variant of {@link CassandraClusterInfo} used when Sidecars are fronted by a load balancer. | ||
| * Replica FQDNs from the token map are not routable from Spark executors in that topology, | ||
| * so time-skew validation must query the configured contact points (load balancer endpoints) | ||
| * rather than per-range replicas. Selected when | ||
| * {@link org.apache.cassandra.spark.bulkwriter.WriterOptions#SIDECAR_BEHIND_LOAD_BALANCER} | ||
| * is set. | ||
| */ | ||
| public class CoordinatedCassandraClusterInfo extends CassandraClusterInfo | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned above, this naming is incorrect, this class is for Cluster behind a LB, nothing specific to Corodinated |
||
| { | ||
| public CoordinatedCassandraClusterInfo(BulkSparkConf conf, String clusterId) | ||
| { | ||
| super(conf, clusterId); | ||
| } | ||
|
|
||
| public CoordinatedCassandraClusterInfo(BroadcastableClusterInfo broadcastable) | ||
| { | ||
| super(broadcastable); | ||
| } | ||
|
|
||
| @Override | ||
| protected CompletableFuture<TimeSkewResponse> fetchTimeSkew(Range<BigInteger> range) | ||
| { | ||
| return getCassandraContext().getSidecarClient().timeSkew(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same problem exists for Single cluster behind a load balancer. Hence instead of using 'Coordinated' word, good to develop this as a generic framework for handling cluster/clusters behind a load balancer, then we can invoke it from anywhere needed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, range param is unused, hence mention a comment something like 'range is irrelevant; contact points are queried directly' |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about single cluster behind a load balancer? Can you create a Jira for supporting this case and add Jira here as a TODO ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend making LB handling as generic framework and invoke it from both coordinated and single cluster case, then we will have uniformity and support for both cases.