外观
antispam-business-livevideo — 直播视频准入检测与直播墙人审处置
分层:业务检测层(点播/直播) | 部署单元:6 个 | 数据库:TiDB
antispam| base image:base-image:jdk17(构建 tagbase-250409)
一、模块定位与架构
本模块是易盾「直播视频 / 直播墙」内容安全产品:客户直播流开播后,对视频流自动抽帧识别涉黄、涉暴、涉政、广告等违规,让审核员在直播墙上一眼看到风险最高的直播间并执行忽略 / 警告 / 提示 / 断流,再把处置结论可靠回传给客户。它承载直播视频反垃圾从准入到人审处置、回调与计量的权威判定与数据留存。
架构分层:
- 协议层:
facade/http-check-api(提交/准入检测)、facade/http-api(回调/查询/实时反馈)、facade/dubbo-check-api+facade/dubbo-check-provider、facade/dubbo-api+facade/dubbo-provider - 逻辑层:
service/business(审核处置/计分/计量/回调)、storage(Kafka 消费/控制消息/CDC/归档) - 数据层:
service/base(MyBatis DAO/Manager/ES Searcher)、domain(实体模型)、common(BO/枚举/常量) - 支撑:
scheduler(Elastic-Job 扫库/归档/告警)、console/api(控制台后端,独立部署)
关键数据流(机器检测):
LiveVideoCheckControllerV4.check(http-check-api提交)→LiveVideoCheckProvider.check(Dubbo 检测链准入)- 入库
live_video+LiveVideoStartCheckService.startCheck调图像组/video/yidun/start - 图像组抽帧检测 → 控制消息 Kafka
yidun_live_video_control StorageApplication内LiveVideoControlConsumer路由 → 截图结果落live_video_data+ 进回调池LiveVideoWallCallbackControllerV4组装回调 → 客户拉取或主动推送- 归档与计量消息 →
antispam-bill
二、可部署服务清单
| 部署单元目录 | artifactId | 镜像名 | 端口 | 服务类型 | 独立 Dockerfile | 是否进 kubernetes.yml |
|---|---|---|---|---|---|---|
facade/dubbo-provider | antispam-business-livevideo-facade-dubbo-provider | antispam-business-livevideo-dubbo-provider | Dubbo 随机 | Dubbo Provider(业务) | 是 | 是(replicas=2) |
facade/dubbo-check-provider | antispam-business-livevideo-facade-dubbo-check-provider | antispam-business-livevideo-dubbo-check-provider | Dubbo 随机 | Dubbo Provider(检测) | 是 | 是(replicas=2) |
facade/http-check-api | antispam-business-livevideo-facade-http-check-api | antispam-business-livevideo-http-check-api | 8401(k8s Service 暴露 80) | HTTP 接入 | 是 | 是(replicas=2) |
facade/http-api | antispam-business-livevideo-facade-http | antispam-business-livevideo-http-api | 8402(k8s Service 暴露 80) | HTTP 接入 | 是 | 是(replicas=2) |
storage | antispam-business-livevideo-storage | antispam-business-livevideo-storage | 无 | Kafka 消费者/Worker | 是 | 是(replicas=2) |
scheduler | antispam-business-livevideo-scheduler | antispam-business-livevideo-scheduler | 无 | 定时任务 | 是 | 是(replicas=2) |
console/api | antispam-business-livevideo-console-api | — | 8080 | 控制台后端 | 无(不构建) | 否 |
k8s 镜像地址统一为
private-registry.yidun.internal/yidun/<镜像名>:1.0.0.private;console/api有启动类但无Dockerfile,不进kubernetes.yml。
三、同模块启动顺序
facade/dubbo-provider— 业务配置/查询服务先就绪,其它单元通过 Dubbo 依赖其契约。facade/dubbo-check-provider— 检测服务,供提交入口调用。storage— 建立 Kafka 消费与入库链路,承接后续提交数据。scheduler— 扫库/归档任务,依赖已落库数据。facade/http-check-api— 对外提交入口,最终暴露。facade/http-api— 回调/查询/反馈入口。
理由:先 provider(内)后 api(外),消费与定时在数据面就绪后启动,避免启动期空扫。
四、逐服务启动逻辑
单元目录 facade/http-check-api
- 启动类:
com.netease.is.antispam.business.livevideo.facade.http.check.HttpCheckApplication(src/main/java/.../facade/http/check/HttpCheckApplication.java) @SpringBootApplication:无 exclude。@Enable*:@EnableBusinessClient、@EnableRateLimiter、@EnableRecoverComponent、@EnableApolloConfig、@EnableI18nComponent。main():无自定义逻辑,直接SpringApplication.run。- 启动钩子:未发现。
单元目录 facade/http-api
- 启动类:
com.netease.is.antispam.business.livevideo.facade.http.HttpApplication(.../facade/http/HttpApplication.java) @SpringBootApplication:无 exclude。@Enable*:@EnableBusinessClient、@EnableOssClient、@EnableCdcDataSubscribe、@EnableRateLimiter、@EnableRecoverComponent、@EnableI18nComponent;另@PropertySources({@PropertySource("classpath:livevideo-oss.properties")})。main():无自定义逻辑。- 启动钩子:未发现(依赖上述
@Enable*拉起的组件)。
单元目录 facade/dubbo-check-provider
- 启动类:
com.netease.is.antispam.business.livevideo.facade.dubbo.check.DubboCheckApplication(.../facade/dubbo/check/DubboCheckApplication.java) @SpringBootApplication:无 exclude。@Enable*:@EnableCdcDataSubscribe、@EnableOssClient、@EnableBusinessClient、@EnableAspectJAutoProxy、@EnableRecoverComponent、@EnableConfigurationProperties({LiveVideoConfig.class})(@ConfigurationProperties(prefix="antispam.checker"))。- 另有
@ComponentScan("com.netease.is.antispam.business.livevideo")、@MapperScan("com.netease.is.antispam.business.livevideo.dao")、@PropertySource("classpath:livevideo-oss.properties")。 main():无自定义逻辑。- 启动钩子:未发现。
单元目录 facade/dubbo-provider
- 启动类:
com.netease.is.antispam.business.livevideo.facade.dubbo.DubboApplication(.../facade/dubbo/DubboApplication.java) @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)— 排除自动数据源,改用手写DataSourceConfig。@Enable*:@EnableBusinessClient、@EnableAspectJAutoProxy、@EnableOssClient、@EnableCdcDataSubscribe、@EnableRecoverComponent、@EnableApolloConfig+@ComponentScan+@MapperScan("...dao")+@PropertySource("livevideo-oss.properties")。DataSourceConfig:masterDataSource(spring.datasource.master)/mirrorDataSource(spring.datasource.mirror)两个 Druid 数据源,@Primary的DynamicDataSource默认指向 master,实现主从切换。main():无自定义逻辑。- 启动钩子:未发现。
单元目录 storage
- 启动类:
com.netease.is.antispam.business.livevideo.storage.StorageApplication(.../storage/StorageApplication.java) @SpringBootApplication:无 exclude。@Enable*:@EnableBusinessClient、@EnableScheduling、@EnableStorageAutoConfiguration、@EnableCdcDataSubscribe、@EnableOssClient、@EnableRecoverComponent、@EnableApolloConfig、@EnableIsolateComponent;@PropertySource("livevideo-oss.properties")。@EnableStorageAutoConfiguration→@Import(StorageConfiguration.class);StorageConfiguration为@ComponentScan({"com.netease.is.antispam.business.livevideo","com.netease.is.antispam.components.callback"})+@MapperScan("...dao")。- 启动钩子
StorageSmartLifecycle implements SmartLifecycle:isAutoStartup()=true、getPhase()=0、start()遍历List<WrapRecover>逐个recover.start()(异常仅记日志),isRunning()恒返回 false。另YidunQosApplication的doOffline先kafkaListenerEndpointRegistry.stop()再逐个 stopConcurrentMessageListenerContainer后sleep 3000。多处@PostConstruct(LiveVideoInsertCache、LiveSpeakerCache、LiveVideoControlConsumer、VideoControlCache、各Abstract*Handler、CdcEsService、BusinessEventListener)。
单元目录 scheduler
- 启动类:
com.netease.is.antispam.business.livevideo.scheduler.SchedulerApplication(.../scheduler/SchedulerApplication.java) @SpringBootApplication:无 exclude。@Enable*:@EnableBusinessClient、@EnableTransactionManagement、@EnableElasticJob、@EnableOssClient、@EnableCdcDataSubscribe、@EnableRecoverComponent、@EnableApolloConfig;@ComponentScan({"com.netease.is.antispam.business.livevideo","com.netease.is.antispam.components.callback.clean","com.netease.is.antispam.components.callback.activeretry"})+@MapperScan("...dao")+@PropertySource("livevideo-oss.properties")。main():无自定义逻辑。- 启动钩子:
LiveMonitorFix、LiveVideoDataFixWorker、BusinessEventListener。
五、启动前置依赖
| 依赖 | 配置键/地址 | 阻塞 or 弱依赖 | 配置文件 |
|---|---|---|---|
| TiDB | spring.datasource.url=jdbc:mysql://tidb-cluster0-tidb.tidb.svc:4000/antispam(http-check) | 阻塞 | application-private.properties |
| Redis Sentinel | spring.redis.sentinel.nodes=redis0-redis-ha.yidun-infra.svc:26379,master=master01 | 阻塞 | application-private.properties |
| ZooKeeper(Dubbo 注册) | zookeeper://zk-*.zookeeper.yidun-infra:2181,group /yidun/antispam/online-new/yidun-antispam-dubbo | 阻塞 | application-private.properties |
| Kafka | common.kafka.bootstrap.servers=kafka-yidun-*.yidun-infra:9092 | 阻塞(storage/http) | application-private.properties |
| Apollo | app.id=antispam-livevideo_http-check / _storage / _scheduler / _dubbo,apollo.bootstrap.enabled=true | 阻塞 | application.properties |
| 业务配置缓存(antispam-business) | business.client.options.zookeeper.address=zk-*.zookeeper.yidun-infra:2181,rootPath=/netease-antispam/online/config | 阻塞 | application-private.properties |
| Elasticsearch 6.5.4 | ES 地址(CDS/检索) | 弱依赖(检索降级) | Apollo |
| OSS | livevideo-oss.properties | 阻塞(@PropertySource 硬引用) | classpath 资源 |
六、启动参数与 Profile
- Spring profiles:默认
dev(application.properties内spring.profiles.active=dev);容器由JAVA_OPTS覆写为private(application-private.properties)。 - Maven profile:
private、dev、test、online、online-jd。 - JAVA_OPTS(k8s):
-Xmx1024m -Xms1024m -XX:+UseG1GC -Dspring.profiles.active=private,并置ENABLE_SKYWALKING=true、SW_AGENT_COLLECTOR_BACKEND_SERVICES=skywalking-skywalking-oap.yidun-infra.svc:11800。 - base image 与仓库:
private-registry.nis.netease.com/library/base-image:jdk17;镜像推送private-registry.nis.netease.com/yidun,tagbase-250409;k8s 拉取private-registry.yidun.internal/yidun/...:1.0.0.private。 - 启动命令:
Dockerfile设ENTRYPOINT ["bash","docker-entrypoint.sh"],APP_NAME形如antispam-business-livevideo-facade-<unit>。 - 构建:
buildAll.sh先mvn clean install -Pprivate,再遍历各子模块build.sh(-c false)构建镜像。
七、启动期踩坑
livevideo-oss.properties在仓库内不存在,但被 4 个单元的@PropertySource硬引用;若 classpath 无此资源,@PropertySource默认ignoreResourceNotFound=false会导致启动失败。- k8s 探针
httpGet /health/status port:80与仓库内server.port=8401/8402不一致;private profile 未显式声明server.port,端口来源不确定,Service 却只暴露 80。 StorageSmartLifecycle.isRunning()恒返回 false,生命周期容器的「运行中」判断失真,可能被重复触发start()。facade/dubbo-provider排除DataSourceAutoConfiguration后完全依赖自建DataSourceConfig,缺spring.datasource.master/mirror配置不会 fail-fast,运行时才暴露。@EnableCdcDataSubscribe在多个单元(http-api、dubbo-check-provider、dubbo-provider、storage、scheduler)同时开启,CDC 订阅重复建立。buildAll.sh用-c false跳过各单元二次编译,会用父构建(可能陈旧)的产物打镜像。- 全部 6 个 Deployment 均
replicas=2且imagePullPolicy: Always,滚动期间 provider 短暂不可用需调用方容错。 degrade.file.file=classpath:sentinel/online/DegradeRule.json引用的规则文件需确认存在于 classpath。
八、跨模块前置
antispam-business:提供SecretInfoCache/TargetCache/ProductCache/TargetConfigCache等鉴权与业务配置缓存,须先启动;ZooKeeper 配置源/netease-antispam/online/config可用。antispam-image:ImageCheckFacade.getCheckParam取检测类型/子标签配置,抽帧结果回传链路依赖它。antispam-keyword/antispam-rule/antispam-list:检测链中的关键词、规则、名单与 IP 区域 checker。antispam-bill:计量消息(REQUEST_STAT、Antispam_Bill_CensorStat)依赖其接收端。- 图像组(仓库外 HTTP 服务):
LiveVideoProxyService调/video/yidun/start|stop|detect;antispam-livevideo-solution等经 Kafkayidun_live提交直播流入库。