diff --git a/stratosphere-clients/src/main/java/eu/stratosphere/client/LocalExecutor.java b/stratosphere-clients/src/main/java/eu/stratosphere/client/LocalExecutor.java index c5edddc5c4d114af315c4776f1869f14a767cb75..89f996aab98bb392b915869679b95ab0fa30d96a 100644 --- a/stratosphere-clients/src/main/java/eu/stratosphere/client/LocalExecutor.java +++ b/stratosphere-clients/src/main/java/eu/stratosphere/client/LocalExecutor.java @@ -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); } diff --git a/stratosphere-clients/src/test/java/eu/stratosphere/client/program/ClientTest.java b/stratosphere-clients/src/test/java/eu/stratosphere/client/program/ClientTest.java index 8056411c3c6399fdf1c245f80c4eb18058c19a5a..479d59a6a69dd509935c8314004e315e72abaab7 100644 --- a/stratosphere-clients/src/test/java/eu/stratosphere/client/program/ClientTest.java +++ b/stratosphere-clients/src/test/java/eu/stratosphere/client/program/ClientTest.java @@ -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(); + } } diff --git a/stratosphere-java/src/main/java/eu/stratosphere/api/java/ExecutionEnvironment.java b/stratosphere-java/src/main/java/eu/stratosphere/api/java/ExecutionEnvironment.java index d948d2dab60736720f9b5c60c21b540e195a3785..1513fe8737e37df3d87950af353e39529ca500e5 100644 --- a/stratosphere-java/src/main/java/eu/stratosphere/api/java/ExecutionEnvironment.java +++ b/stratosphere-java/src/main/java/eu/stratosphere/api/java/ExecutionEnvironment.java @@ -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; + } }