Spark任务的thrift冲突问题(logging-assembly)

it2025-03-17  24

因为项目是使用到了 org.apache.thrift,在任务执行过程中,遇到了各种因thrift引起的jar包冲突问题

解决方法一

第一个想到的是shade

<relocation> <pattern>org.apache.thrift</pattern> <shadedPattern>shade.org.apache.thrift</shadedPattern> </relocation>

最后一个stage解决了,但是由引起了其他stage的冲突,因为有些内部包使用org.apache.thrift中的org.apache.thrift.TBase

抛出异常can not cast be shade.org.apache.thrift.TBase

继续对这些内部包做shade

........

如此往复,做了N个shade总算是可以正常运行了

解决方法二

Spark环境的jars中有 logging-assembly-0.1.0-protobuf3.jar

而它里面有 thrift、neo、ycluster

于是复制了一个spark环境,从jars中删除了该jar包,不需要shade,任务也可以正常运行

该包对某些场景有影响,需要自行在项目中引入

比较

方法一,不需要动统一的spark环境,就是引入新的使用thrift的包时,要记得做shade方法二,不需要做各种shade,但是需要复制一个单独的spark环境,当公司的spark升级时,还要跟着复制最新的,而且有些需要logging-assembly时,要自行在pom中引入
最新回复(0)