testFetchAds方法报错

来源:14-5 编写广告检索系统的测试用例(下)

幕布斯1199021

2023-02-21

[org.springframework.context.annotation.AnnotationConfigApplicationContext@38eb2c50: startup date [Tue Feb 21 21:07:41 CST 2023]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6de54b40] and template loader path [classpath:/templates/]
2023-02-21 21:07:46.470  INFO 97973 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483547
2023-02-21 21:07:46.503  INFO 97973 --- [           main] o.a.k.clients.consumer.ConsumerConfig    : ConsumerConfig values: 
	auto.commit.interval.ms = 5000
	auto.offset.reset = latest
	bootstrap.servers = [localhost:9092]
	check.crcs = true
	client.id = 
	connections.max.idle.ms = 540000
	enable.auto.commit = true
	exclude.internal.topics = true
	fetch.max.bytes = 52428800
	fetch.max.wait.ms = 500
	fetch.min.bytes = 1
	group.id = ad-search
	heartbeat.interval.ms = 3000
	interceptor.classes = null
	internal.leave.group.on.close = true
	isolation.level = read_uncommitted
	key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
	max.partition.fetch.bytes = 1048576
	max.poll.interval.ms = 300000
	max.poll.records = 500
	metadata.max.age.ms = 300000
	metric.reporters = []
	metrics.num.samples = 2
	metrics.recording.level = INFO
	metrics.sample.window.ms = 30000
	partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
	receive.buffer.bytes = 65536
	reconnect.backoff.max.ms = 1000
	reconnect.backoff.ms = 50
	request.timeout.ms = 305000
	retry.backoff.ms = 100
	sasl.jaas.config = null
	sasl.kerberos.kinit.cmd = /usr/bin/kinit
	sasl.kerberos.min.time.before.relogin = 60000
	sasl.kerberos.service.name = null
	sasl.kerberos.ticket.renew.jitter = 0.05
	sasl.kerberos.ticket.renew.window.factor = 0.8
	sasl.mechanism = GSSAPI
	security.protocol = PLAINTEXT
	send.buffer.bytes = 131072
	session.timeout.ms = 10000
	ssl.cipher.suites = null
	ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
	ssl.endpoint.identification.algorithm = null
	ssl.key.password = null
	ssl.keymanager.algorithm = SunX509
	ssl.keystore.location = null
	ssl.keystore.password = null
	ssl.keystore.type = JKS
	ssl.protocol = TLS
	ssl.provider = null
	ssl.secure.random.implementation = null
	ssl.trustmanager.algorithm = PKIX
	ssl.truststore.location = null
	ssl.truststore.password = null
	ssl.truststore.type = JKS
	value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer

2023-02-21 21:07:46.579  INFO 97973 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 1.0.1
2023-02-21 21:07:46.579  INFO 97973 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : c0518aa65f25317e
2023-02-21 21:07:46.586  INFO 97973 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 
2023-02-21 21:07:46.606  INFO 97973 --- [           main] com.imooc.ad.search.SearchTest           : Started SearchTest in 6.616 seconds (JVM running for 7.698)
2023-02-21 21:07:46.608  INFO 97973 --- [           main] com.imooc.ad.runner.BinlogRunner         : Coming in BinlogRunner...
2023-02-21 21:08:32.372  INFO 97973 --- [       Thread-9] com.imooc.ad.mysql.BinlogClient          : connecting to mysql start
2023-02-21 21:08:33.947  INFO 97973 --- [       Thread-9] c.g.shyiko.mysql.binlog.BinaryLogClient  : Connected to 127.0.0.1:3306 at binlog.000028/23099 (sid:65535, cid:458)
2023-02-21 21:08:33.991  WARN 97973 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-1, groupId=ad-search] Connection to node -1 could not be established. Broker may not be available.
{"featureInfo":{"districtFeature":{"districts":[{"city":"合肥市","province":"安徽省"}]},"itFeature":{"its":["台球","游泳"]},"keywordFeature":{"keywords":["宝马","大众"]},"relation":"OR"},"mediaId":"imooc-ad","requestInfo":{"adSlots":[{"adSlotCode":"ad-x","height":720,"minCpm":1000,"positionType":1,"type":[1,2],"width":1080}],"app":{"activityName":"video","appCode":"imooc","appName":"imooc","packageName":"com.imooc"},"device":{"deviceCode":"iphone","displaySize":"1080 720","ip":"127.0.0.1","mac":"0xxxxx","model":"x","screenSize":"1080 720","serialName":"123456789"},"geo":{"city":"北京市","latitude":100.28,"longitude":88.61,"province":"北京市"},"requestId":"aaa"}}
2023-02-21 21:08:34.030  INFO 97973 --- [           main] com.imooc.ad.search.impl.SearchImpl      : fetchAds:{"featureInfo":{"districtFeature":{"districts":[{"city":"合肥市","province":"安徽省"}]},"itFeature":{"its":["台球","游泳"]},"keywordFeature":{"keywords":["宝马","大众"]},"relation":"OR"},"mediaId":"imooc-ad","requestInfo":{"adSlots":[{"adSlotCode":"ad-x","height":720,"minCpm":1000,"positionType":1,"type":[1,2],"width":1080}],"app":{"activityName":"video","appCode":"imooc","appName":"imooc","packageName":"com.imooc"},"device":{"deviceCode":"iphone","displaySize":"1080 720","ip":"127.0.0.1","mac":"0xxxxx","model":"x","screenSize":"1080 720","serialName":"123456789"},"geo":{"city":"北京市","latitude":100.28,"longitude":88.61,"province":"北京市"},"requestId":"aaa"}}-{"adSlot2Ads":{"ad-x":[]}}
{"adSlot2Ads":{"ad-x":[]}}
{"featureInfo":{"districtFeature":{"districts":[{"city":"合肥市","province":"安徽省"}]},"itFeature":{"its":["台球","游泳"]},"keywordFeature":{"keywords":["宝马","大众","标志"]},"relation":"AND"},"mediaId":"imooc-ad","requestInfo":{"adSlots":[{"adSlotCode":"ad-y","height":720,"minCpm":1000,"positionType":1,"type":[1,2],"width":1080}],"app":{"activityName":"video","appCode":"imooc","appName":"imooc","packageName":"com.imooc"},"device":{"deviceCode":"iphone","displaySize":"1080 720","ip":"127.0.0.1","mac":"0xxxxx","model":"x","screenSize":"1080 720","serialName":"123456789"},"geo":{"city":"北京市","latitude":100.28,"longitude":88.61,"province":"北京市"},"requestId":"aaa"}}
2023-02-21 21:08:34.031  INFO 97973 --- [           main] com.imooc.ad.search.impl.SearchImpl      : fetchAds:{"featureInfo":{"districtFeature":{"districts":[{"city":"合肥市","province":"安徽省"}]},"itFeature":{"its":["台球","游泳"]},"keywordFeature":{"keywords":["宝马","大众","标志"]},"relation":"AND"},"mediaId":"imooc-ad","requestInfo":{"adSlots":[{"adSlotCode":"ad-y","height":720,"minCpm":1000,"positionType":1,"type":[1,2],"width":1080}],"app":{"activityName":"video","appCode":"imooc","appName":"imooc","packageName":"com.imooc"},"device":{"deviceCode":"iphone","displaySize":"1080 720","ip":"127.0.0.1","mac":"0xxxxx","model":"x","screenSize":"1080 720","serialName":"123456789"},"geo":{"city":"北京市","latitude":100.28,"longitude":88.61,"province":"北京市"},"requestId":"aaa"}}-{"adSlot2Ads":{"ad-y":[]}}
{"adSlot2Ads":{"ad-y":[]}}
2023-02-21 21:08:34.037  INFO 97973 --- [       Thread-8] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@38eb2c50: startup date [Tue Feb 21 21:07:41 CST 2023]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6de54b40
2023-02-21 21:08:34.038  INFO 97973 --- [       Thread-8] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483547
2023-02-21 21:08:34.042  INFO 97973 --- [ntainer#0-0-C-1] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService
2023-02-21 21:08:34.046  INFO 97973 --- [ntainer#0-0-C-1] essageListenerContainer$ListenerConsumer : Consumer stopped
2023-02-21 21:08:34.046  INFO 97973 --- [       Thread-8] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2023-02-21 21:08:34.060  INFO 97973 --- [       Thread-8] s.c.a.AnnotationConfigApplicationContext : Closing FeignContext-eureka-client-ad-sponsor: startup date [Tue Feb 21 21:07:44 CST 2023]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@38eb2c50
2023-02-21 21:08:34.061  INFO 97973 --- [       Thread-8] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-02-21 21:08:34.063  INFO 97973 --- [       Thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-02-21 21:08:34.077  INFO 97973 --- [       Thread-8] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
Disconnected from the target VM, address: '127.0.0.1:60199', transport: 'socket'

Process finished with exit code 0

老师您好,在测试类testFetchAds方法的时候报错,报错信息如上,{“adSlot2Ads”:{“ad-x”:[]}} ad-x中没数据 且没有打印增量索引before add: {} after add: {}这样的信息,麻烦能帮忙看下可能是什么原因吗?

写回答

1回答

张勤一

2023-02-22

增量索引就是读取 MySQL 的 binlog,再去解析;首先要保证的是和 MySQL 的配置连接都是正常的,也能够读取到 binlog。

1
1
幕布斯1199021
原来是indexFileLoader的init方法上面没写@PostConstruct注释
2023-02-24
共1条回复

Spring Cloud微服务架构 设计实现广告系统

广告营销系统,未来大中型企业的标配

2136 学习 · 927 问题

查看课程