Class CassandraClusterInfoGroup

  • All Implemented Interfaces:
    MultiClusterSupport<ClusterInfo>, ClusterInfo, StartupValidatable

    public class CassandraClusterInfoGroup
    extends java.lang.Object
    implements ClusterInfo, MultiClusterSupport<ClusterInfo>
    A group of ClusterInfo. One per cluster. The class does the aggregation over all clusters for applicable operations.

    This class is NOT serialized and does NOT have a serialVersionUID. When broadcasting to executors, the driver extracts information from this class and creates a BroadcastableClusterInfoGroup instance, which is then included in the BulkWriterConfig that gets broadcast.

    This class implements Serializable only because the ClusterInfo interface requires it (for use as a field type in broadcast classes), but instances of this class are never directly serialized.

    • Method Detail

      • from

        public static CassandraClusterInfoGroup from​(BroadcastableClusterInfoGroup broadcastable)
        Reconstruct from BroadcastableClusterInfoGroup on executor. Creates CassandraClusterInfo instances for each cluster that will fetch data from Sidecar. Leverages pre-computed values (partitioner, lowestCassandraVersion) from the broadcastable to avoid re-validation and re-computation on executors.
        Parameters:
        broadcastable - the broadcastable cluster info group from broadcast
        Returns:
        new CassandraClusterInfoGroup instance
      • getLowestCassandraVersion

        public java.lang.String getLowestCassandraVersion()
        Specified by:
        getLowestCassandraVersion in interface ClusterInfo
        Returns:
        the lowest cassandra version among all clusters
      • getPartitioner

        public org.apache.cassandra.spark.data.partitioner.Partitioner getPartitioner()
        Specified by:
        getPartitioner in interface ClusterInfo
      • validateTimeSkew

        public void validateTimeSkew​(com.google.common.collect.Range<java.math.BigInteger> range)
                              throws org.apache.cassandra.spark.exception.SidecarApiCallException,
                                     org.apache.cassandra.spark.exception.TimeSkewTooLargeException
        Description copied from interface: ClusterInfo
        Validate whether the time skew of the replicas of the range is acceptable
        Specified by:
        validateTimeSkew in interface ClusterInfo
        Parameters:
        range - token range used to look up the relevant replicas
        Throws:
        org.apache.cassandra.spark.exception.SidecarApiCallException - when fails to retrieve time skew information
        org.apache.cassandra.spark.exception.TimeSkewTooLargeException - when the time skew has exceeded the allowance
      • getKeyspaceSchema

        public java.lang.String getKeyspaceSchema​(boolean cached)
        Description copied from interface: ClusterInfo
        Return the keyspace schema string of the enclosing keyspace for bulk write in the cluster
        Specified by:
        getKeyspaceSchema in interface ClusterInfo
        Parameters:
        cached - whether using the cached schema information
        Returns:
        keyspace schema string
      • replicationFactor

        public org.apache.cassandra.spark.data.ReplicationFactor replicationFactor()
        Specified by:
        replicationFactor in interface ClusterInfo
        Returns:
        ReplicationFactor of the enclosing keyspace for bulk write in the cluster
      • startupValidate

        public void startupValidate()
        Description copied from interface: StartupValidatable
        Performs startup validation using StartupValidator with currently registered StartupValidations, throws a RuntimeException if any violations are found, needs to be invoked once per execution before any actual work is started
        Specified by:
        startupValidate in interface StartupValidatable
      • clusterId

        public java.lang.String clusterId()
        Description copied from interface: ClusterInfo
        ID string that can uniquely identify a cluster

        Implementor note: the method is optional. When writing to a single cluster, there is no requirement of assigning an ID for bulk write to proceed. When in the coordinated write mode, i.e. writing to multiple clusters, the method must be implemented and return unique string for clusters.

        Specified by:
        clusterId in interface ClusterInfo
        Returns:
        cluster id string, null if absent
      • getValueOrNull

        @Nullable
        public ClusterInfo getValueOrNull​(@NotNull
                                          java.lang.String clusterId)
        Description copied from interface: MultiClusterSupport
        Look up a value based on clusterId
        Specified by:
        getValueOrNull in interface MultiClusterSupport<ClusterInfo>
        Parameters:
        clusterId - cluster id
        Returns:
        the value of type T associated with the clusterId, or null if not found