Skip to content

Commit

Permalink
W-11492245: Fix CheckPointMgr null check for cjclient as Kinesis cons…
Browse files Browse the repository at this point in the history
…umer
  • Loading branch information
peterzxu committed Jul 24, 2023
1 parent 0a82d98 commit 3fea476
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public KinesisConsumer(MetricRegistry metricRegistry, PointProcessor pointProces
this.kinesisStreamName = kinesisStreamName;
this.kinesisApplicationName = kinesisApplicationName;
this.kinesisConfig = kinesisConfig;
this.checkPointMgr = Preconditions.checkNotNull(checkPointMgr);
this.checkPointMgr = checkPointMgr;
this.noOfRestarts = noOfRestarts;
this.kinesisConsumerRegion = kinesisConsumerRegion;
log.info("Kinesis consumer started");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.demandware.carbonj.service.accumulator.Accumulator;
import com.demandware.carbonj.service.accumulator.cfgAccumulator;
import com.demandware.carbonj.service.engine.*;
import com.demandware.carbonj.service.engine.CheckPointMgr;
import com.demandware.carbonj.service.engine.DynamoDbCheckPointMgr;
import com.demandware.carbonj.service.engine.FileCheckPointMgr;
import com.demandware.carbonj.service.engine.KinesisConfig;
import com.demandware.carbonj.service.engine.cfgCarbonJ;
import com.demandware.carbonj.service.engine.cfgKinesis;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -47,10 +52,13 @@ CheckPointMgr<Date> checkPointMgr(ScheduledExecutorService s, KinesisConfig kine
@Autowired( required = false ) @Qualifier( "accumulator" ) Accumulator accu )
throws Exception
{
if ( !kinesisConfig.isKinesisConsumerEnabled() || accu == null )
if (!kinesisConfig.isKinesisConsumerEnabled()) {
log.warn("CheckPointMgr is disabled because kinesis consumer is disabled");
return null;
}
if (accu == null)
{
log.debug( "CheckPointMgr is disabled because kinesis consumer is disabled or accumulator is null: Kinesis"
+ " consumer: {}, Accumulator: {}", kinesisConfig.isKinesisConsumerEnabled(), accu );
log.warn("CheckPointMgr is disabled because accumulator is null");
return null;
}

Expand Down Expand Up @@ -84,4 +92,4 @@ CheckPointMgr<Date> checkPointMgr(ScheduledExecutorService s, KinesisConfig kine
}, 120, 60, TimeUnit.SECONDS );
return checkPointMgr;
}
}
}

0 comments on commit 3fea476

Please sign in to comment.