3030import com .datastax .cdm .job .IJobSessionFactory .JobType ;
3131import com .datastax .cdm .properties .KnownProperties ;
3232import com .datastax .cdm .properties .PropertyHelper ;
33+ import com .datastax .cdm .schema .ClusterConfigurationException ;
3334import com .datastax .cdm .schema .CqlTable ;
3435import com .datastax .oss .driver .api .core .CqlSession ;
3536import com .datastax .oss .driver .shaded .guava .common .util .concurrent .RateLimiter ;
@@ -55,45 +56,53 @@ protected AbstractJobSession(CqlSession originSession, CqlSession targetSession,
5556 return ;
5657 }
5758
58- rateLimiterOrigin = RateLimiter .create (propertyHelper .getInteger (KnownProperties .PERF_RATELIMIT_ORIGIN ));
59- rateLimiterTarget = RateLimiter .create (propertyHelper .getInteger (KnownProperties .PERF_RATELIMIT_TARGET ));
60-
61- logger .info ("PARAM -- Origin Rate Limit: {}" , rateLimiterOrigin .getRate ());
62- logger .info ("PARAM -- Target Rate Limit: {}" , rateLimiterTarget .getRate ());
63-
64- CqlTable cqlTableOrigin , cqlTableTarget = null ;
65- this .originSession = new EnhancedSession (propertyHelper , originSession , true );
66- cqlTableOrigin = this .originSession .getCqlTable ();
67- cqlTableOrigin .setFeatureMap (featureMap );
68-
69- boolean allFeaturesValid = true ;
70- if (targetSession != null ) {
71- this .targetSession = new EnhancedSession (propertyHelper , targetSession , false );
72- cqlTableTarget = this .targetSession .getCqlTable ();
73- cqlTableOrigin .setOtherCqlTable (cqlTableTarget );
74- cqlTableTarget .setOtherCqlTable (cqlTableOrigin );
75- cqlTableTarget .setFeatureMap (featureMap );
76- for (Feature f : featureMap .values ()) {
77- if (!f .initializeAndValidate (cqlTableOrigin , cqlTableTarget )) {
78- allFeaturesValid = false ;
79- logger .error ("Feature {} is not valid. Please check the configuration." , f .getClass ().getName ());
59+ try {
60+ rateLimiterOrigin = RateLimiter .create (propertyHelper .getInteger (KnownProperties .PERF_RATELIMIT_ORIGIN ));
61+ rateLimiterTarget = RateLimiter .create (propertyHelper .getInteger (KnownProperties .PERF_RATELIMIT_TARGET ));
62+
63+ logger .info ("PARAM -- Origin Rate Limit: {}" , rateLimiterOrigin .getRate ());
64+ logger .info ("PARAM -- Target Rate Limit: {}" , rateLimiterTarget .getRate ());
65+
66+ CqlTable cqlTableOrigin , cqlTableTarget = null ;
67+ this .originSession = new EnhancedSession (propertyHelper , originSession , true );
68+ cqlTableOrigin = this .originSession .getCqlTable ();
69+ cqlTableOrigin .setFeatureMap (featureMap );
70+
71+ boolean allFeaturesValid = true ;
72+ if (targetSession != null ) {
73+ this .targetSession = new EnhancedSession (propertyHelper , targetSession , false );
74+ cqlTableTarget = this .targetSession .getCqlTable ();
75+ cqlTableOrigin .setOtherCqlTable (cqlTableTarget );
76+ cqlTableTarget .setOtherCqlTable (cqlTableOrigin );
77+ cqlTableTarget .setFeatureMap (featureMap );
78+ for (Feature f : featureMap .values ()) {
79+ if (!f .initializeAndValidate (cqlTableOrigin , cqlTableTarget )) {
80+ allFeaturesValid = false ;
81+ logger .error ("Feature {} is not valid. Please check the configuration." , f .getClass ().getName ());
82+ }
8083 }
81- }
8284
83- PKFactory pkFactory = new PKFactory (propertyHelper , cqlTableOrigin , cqlTableTarget );
84- this .originSession .setPKFactory (pkFactory );
85- this .targetSession .setPKFactory (pkFactory );
86- }
85+ PKFactory pkFactory = new PKFactory (propertyHelper , cqlTableOrigin , cqlTableTarget );
86+ this .originSession .setPKFactory (pkFactory );
87+ this .targetSession .setPKFactory (pkFactory );
88+ }
8789
88- if (!allFeaturesValid ) {
89- throw new RuntimeException ("One or more features are not valid. Please check the configuration." );
90- }
90+ if (!allFeaturesValid ) {
91+ throw new RuntimeException ("One or more features are not valid. Please check the configuration." );
92+ }
9193
92- this .guardrailFeature = (Guardrail ) cqlTableOrigin .getFeature (Featureset .GUARDRAIL_CHECK );
93- if (!guardrailFeature .initializeAndValidate (cqlTableOrigin , null )) {
94- allFeaturesValid = false ;
95- logger .error ("Feature {} is not valid. Please check the configuration." ,
96- guardrailFeature .getClass ().getName ());
94+ this .guardrailFeature = (Guardrail ) cqlTableOrigin .getFeature (Featureset .GUARDRAIL_CHECK );
95+ if (!guardrailFeature .initializeAndValidate (cqlTableOrigin , null )) {
96+ allFeaturesValid = false ;
97+ logger .error ("Feature {} is not valid. Please check the configuration." ,
98+ guardrailFeature .getClass ().getName ());
99+ }
100+ } catch (ClusterConfigurationException e ) {
101+ logger .error ("Cluster configuration error may be present & detected: {}" , e .getMessage ());
102+ logger .error ("Please check your Cassandra cluster for token overlap issues. This usually happens when multiple nodes in the cluster were started simultaneously when the cluster was originally built." );
103+ logger .error ("You can verify this by running 'nodetool describering <keyspace>' and checking for overlapping token ranges." );
104+ logger .error ("In general, to fix token overlap in a cluster: 1) Rebuild the entire cluster by removing nodes 2) Re-add nodes one at a time 3) Run nodetool cleanup on each node 4) Verify with 'nodetool describering <keyspace>'" );
105+ throw e ;
97106 }
98107 }
99108
0 commit comments