SparkLauncher执行spark程序一直阻塞卡在running-undefined的情况处理

使用SparkLauncher提交spark程序时,有时间会一直卡在status是running状态 finalstatus为undefined,这种情况是因为使用的java的ProcessBuilder,查阅了资料后发现可能是因为buffer被填满,导致进程的阻塞。

官方文档内也有相关提示:

By default, the created subprocess does not have its own terminal or console. All its standard I/O (i.e. stdin, stdout, stderr) operations will be redirected to the parent process, where they can be accessed via the streams obtained using the methods getOutputStream(), getInputStream(), and getErrorStream(). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, or even deadlock.
-------------------------------------------------------------------------------

默认情况下,创建的子进程没有自己的终端或控制台。它的所有标准I/O(即,stdin、stdout、stderr)操作将被重定向到父进程,在那里可以通过使用方法getOutputStream()、getInputStream()和getErrorStream()获得的流来访问它们。父进程使用这些流来输入输入并从子进程获取输出。由于一些本机平台仅对标准输入和输出流提供有限的缓冲区大小,因此不能及时写入输入流或读取子进程的输出流可能导致子进程阻塞,甚至死锁。

所以我们要自己开启子线程读取相应的buffer内容,最重要的是其中的getErrorStream(),一般spark的info信息都在这个里面.

 

 

 

转载于:https://my.oschina.net/u/3398895/blog/2885217

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值