最近公司准备使用spark做流式计算,把原来做过的东西拿出来整理一下,有以下内容
1、通过java调用shell脚本启动spark
2、在虚拟机退出时执行特定的方法即注册一个回调函数
对于Runtime类的测试<br/>Every Java application has a single instance of class Runtime
that allows the application to interface with the environment in
which the application is running.
每个java应用程序都有一个RunTime运行时环境的实例,该实例是单例的,它代表着正在运行的应用程序的环境
The current runtime can be obtained from the getRuntime method.
An application cannot create its own instance of this class
当前的运行时环境可以通过getRuntime方法获取,一个运行时环境不能创建自己的运行时环境的实例
package com.lyzx.linux;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class RunTimeTest {
public static void main(String[] args) {
// normalExit();
unNormalExit();
}
/**
* 使用java调用shell脚本,
* //shell脚本内容如下:spark-submit --master spark://master:7077 --class com.lyzx.pi.M /root/package