我使用 ProcessBuilder
,但我没有得到任何价值。它显示一个空结果。
这是我的密码:
package webservice;
import java.io.IOException;
import java.io.InputStream;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
@Path("/hello")
public class HelloWorldService {
@GET
@Path("/{param}/{param2}/{param3}")
public Response getMsg(@PathParam("param") String bedroom,@PathParam("param2") String bathroom,@PathParam("param3")String area) throws IOException {
ProcessBuilder pb = new ProcessBuilder("/script/spark-submit.sh");
pb.environment().put("a", bedroom);
pb.environment().put("b", bathroom);
pb.environment().put("c", area);
Process p=pb.start();
InputStream is = p.getInputStream();
int i =0;
StringBuffer sb = new StringBuffer();
while((i=is.read())!=-1)
sb.append((char)i);
System.out.println("value of sb:"+sb.toString());
String a =sb.toString();
System.out.println("value of a:"+a);
String[] arr = a.split(" ");
if (arr != null)
{
System.out.println("predicted value is " + arr[arr.length - 1]);
}
String output = "predicted value is " + arr[arr.length - 1];
return Response.status(200).entity(output).build();
}
}
shell脚本代码
spark-submit --class scalatest.scalatest.scalatest --master local[4] /home/ec2-user/scalatest-0.0.1-SNAPSHOT.jar $a $b $c
2条答案
按热度按时间slmsl1lt1#
尝试使用
xn1cxnb42#
尝试使用
你的过程似乎从未真正开始过