Java 错误的请求:“;需求失败:会话不为';t激活;在阿帕奇利维
代码:Java 错误的请求:“;需求失败:会话不为';t激活;在阿帕奇利维,java,apache,livy,Java,Apache,Livy,代码: 如何解决此错误?请与我联系。这方面运气好吗?我在0.6.0孵化中也遇到了同样的错误 public class PiApp { public static void main(String[] args) throws Exception { LivyClient client = new LivyClientBuilder().setURI(new URI("http://localhost:8998/")).build(); try { Syste
如何解决此错误?请与我联系。这方面运气好吗?我在0.6.0孵化中也遇到了同样的错误
public class PiApp
{
public static void main(String[] args) throws Exception {
LivyClient client = new LivyClientBuilder().setURI(new URI("http://localhost:8998/")).build();
try {
System.out.println("Uploading livy-example jar to the SparkContext...");
for (String s : System.getProperty("java.class.path").split(File.pathSeparator)) {
System.out.println("Enter to for");
if (new File(s).getName().startsWith("livy_1")) {
System.out.println("Enter to if");
client.uploadJar(new File(s)).get();
break;
}
}
final int slices = Integer.parseInt("2");
System.out.println("submitting");
try {
double pi = client.submit(new PiJob(slices)).get();
System.out.println("Pi is roughly " + pi);
} catch (Exception e) {
System.out.println("Enter to catch");
System.out.println(e.getMessage());
}
} finally {
client.stop(true);
}
}
}
@SuppressWarnings("serial")
class PiJob implements Job<Double>, Function<Integer, Integer>,
Function2<Integer, Integer, Integer> {
private final int slices;
private final int samples;
public PiJob(int slices) {
this.slices = slices;
this.samples = (int) Math.min(100000L * slices, Integer.MAX_VALUE);
}
public Double call(JobContext ctx) throws Exception {
List<Integer> sampleList = new ArrayList<Integer>();
for (int i = 0; i < samples; i++) {
sampleList.add(i);
}
return 4.0d * ctx.sc().parallelize(sampleList, slices).map(this).reduce(this) / samples;
}
public Integer call(Integer v1) {
double x = Math.random() * 2 - 1;
double y = Math.random() * 2 - 1;
return (x * x + y * y < 1) ? 1 : 0;
}
public Integer call(Integer v1, Integer v2) {
return v1 + v2;
}
}
java.io.IOException: Bad Request: "requirement failed: Session isn't active."