提交 f90f172c 编写于 作者: S StephanEwen

Disable also local environment in client submission settings.

上级 81522149
......@@ -17,10 +17,12 @@ import java.util.List;
import org.apache.log4j.Level;
import eu.stratosphere.api.common.InvalidProgramException;
import eu.stratosphere.api.common.JobExecutionResult;
import eu.stratosphere.api.common.Plan;
import eu.stratosphere.api.common.PlanExecutor;
import eu.stratosphere.api.common.Program;
import eu.stratosphere.api.java.ExecutionEnvironment;
import eu.stratosphere.client.minicluster.NepheleMiniCluster;
import eu.stratosphere.compiler.DataStatistics;
import eu.stratosphere.compiler.PactCompiler;
......@@ -63,6 +65,10 @@ public class LocalExecutor extends PlanExecutor {
// --------------------------------------------------------------------------------------------
public LocalExecutor() {
if (!ExecutionEnvironment.localExecutionIsAllowed()) {
throw new InvalidProgramException("The LocalEnvironment cannot be used when submitting a program through a client.");
}
if (System.getProperty("log4j.configuration") == null) {
setLoggingLevel(Level.INFO);
}
......
......@@ -31,6 +31,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import eu.stratosphere.api.common.InvalidProgramException;
import eu.stratosphere.api.common.Plan;
import eu.stratosphere.api.java.LocalEnvironment;
import eu.stratosphere.client.LocalExecutor;
import eu.stratosphere.compiler.DataStatistics;
import eu.stratosphere.compiler.PactCompiler;
......@@ -134,15 +135,16 @@ public class ClientTest {
verify(this.jobClientMock).submitJob();
}
/**
* @throws Exception
*/
@Test(expected=InvalidProgramException.class)
public void tryLocalExecution() throws Exception
{
when(jobSubmissionResultMock.getReturnCode()).thenReturn(ReturnCode.ERROR);
Client out = new Client(configMock);
public void tryLocalExecution() throws Exception {
new Client(configMock);
LocalExecutor.execute(planMock);
}
@Test(expected=InvalidProgramException.class)
public void tryLocalEnvironmentExecution() throws Exception {
new Client(configMock);
new LocalEnvironment();
}
}
......@@ -498,11 +498,11 @@ public abstract class ExecutionEnvironment {
return contextEnvironment != null;
}
protected static boolean localExecutionIsAllowed() {
return allowLocalExecution;
}
protected static void disableLocalExecution() {
allowLocalExecution = false;
}
public static boolean localExecutionIsAllowed() {
return allowLocalExecution;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册