You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by rm...@apache.org on 2014/06/18 14:00:34 UTC

[14/15] git commit: extended plan-dump test for KMeans

extended plan-dump test for KMeans


Project: http://git-wip-us.apache.org/repos/asf/incubator-flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-flink/commit/5484d58e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-flink/tree/5484d58e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-flink/diff/5484d58e

Branch: refs/heads/master
Commit: 5484d58e56a7fdb5ff7a9e9edff8ef73e27e7c71
Parents: a84f8a1
Author: Robert Metzger <me...@web.de>
Authored: Wed Jun 18 12:16:11 2014 +0200
Committer: Robert Metzger <me...@web.de>
Committed: Wed Jun 18 12:16:11 2014 +0200

----------------------------------------------------------------------
 .../eu/stratosphere/client/program/Client.java  |  2 +-
 .../client/program/PackagedProgram.java         | 11 ++++++++---
 .../compiler/plandump/DumpCompiledPlanTest.java | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/5484d58e/stratosphere-clients/src/main/java/eu/stratosphere/client/program/Client.java
----------------------------------------------------------------------
diff --git a/stratosphere-clients/src/main/java/eu/stratosphere/client/program/Client.java b/stratosphere-clients/src/main/java/eu/stratosphere/client/program/Client.java
index a9e5437..00790f4 100644
--- a/stratosphere-clients/src/main/java/eu/stratosphere/client/program/Client.java
+++ b/stratosphere-clients/src/main/java/eu/stratosphere/client/program/Client.java
@@ -367,7 +367,7 @@ public class Client {
 		}
 	}
 	
-	static final class ProgramAbortException extends Error {
+	public static final class ProgramAbortException extends Error {
 		private static final long serialVersionUID = 1L;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/5484d58e/stratosphere-clients/src/main/java/eu/stratosphere/client/program/PackagedProgram.java
----------------------------------------------------------------------
diff --git a/stratosphere-clients/src/main/java/eu/stratosphere/client/program/PackagedProgram.java b/stratosphere-clients/src/main/java/eu/stratosphere/client/program/PackagedProgram.java
index 6e09ad4..51d2e34 100644
--- a/stratosphere-clients/src/main/java/eu/stratosphere/client/program/PackagedProgram.java
+++ b/stratosphere-clients/src/main/java/eu/stratosphere/client/program/PackagedProgram.java
@@ -637,13 +637,14 @@ public class PackagedProgram {
 	
 	// --------------------------------------------------------------------------------------------
 	
-	private static final class PreviewPlanEnvironment extends ExecutionEnvironment {
+	public static final class PreviewPlanEnvironment extends ExecutionEnvironment {
 
 		private List<DataSinkNode> previewPlan;
+		private Plan plan;
 		
 		@Override
 		public JobExecutionResult execute(String jobName) throws Exception {
-			Plan plan = createProgramPlan(jobName);
+			this.plan = createProgramPlan(jobName);
 			this.previewPlan = PactCompiler.createPreOptimizedPlan(plan);
 			
 			// do not go on with anything now!
@@ -659,8 +660,12 @@ public class PackagedProgram {
 			throw new Client.ProgramAbortException();
 		}
 		
-		private void setAsContext() {
+		public void setAsContext() {
 			initializeContextEnvironment(this);
 		}
+
+		public Plan getPlan() {
+			return this.plan;
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/5484d58e/stratosphere-tests/src/test/java/eu/stratosphere/test/compiler/plandump/DumpCompiledPlanTest.java
----------------------------------------------------------------------
diff --git a/stratosphere-tests/src/test/java/eu/stratosphere/test/compiler/plandump/DumpCompiledPlanTest.java b/stratosphere-tests/src/test/java/eu/stratosphere/test/compiler/plandump/DumpCompiledPlanTest.java
index 429d3e2..233b418 100644
--- a/stratosphere-tests/src/test/java/eu/stratosphere/test/compiler/plandump/DumpCompiledPlanTest.java
+++ b/stratosphere-tests/src/test/java/eu/stratosphere/test/compiler/plandump/DumpCompiledPlanTest.java
@@ -19,8 +19,11 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import eu.stratosphere.api.common.Plan;
+import eu.stratosphere.client.program.Client.ProgramAbortException;
+import eu.stratosphere.client.program.PackagedProgram.PreviewPlanEnvironment;
 import eu.stratosphere.compiler.plan.OptimizedPlan;
 import eu.stratosphere.compiler.plandump.PlanJSONDumpGenerator;
+import eu.stratosphere.example.java.clustering.KMeans;
 import eu.stratosphere.test.compiler.util.CompilerTestBase;
 import eu.stratosphere.test.recordJobs.graph.DeltaPageRankWithInitialDeltas;
 import eu.stratosphere.test.recordJobs.kmeans.KMeansBroadcast;
@@ -50,6 +53,23 @@ public class DumpCompiledPlanTest extends CompilerTestBase {
 	}
 	
 	@Test
+	public void dumpIterativeKMeans() {
+		// prepare the test environment
+		PreviewPlanEnvironment env = new PreviewPlanEnvironment();
+		env.setAsContext();
+		try {
+			// <points path> <centers path> <result path> <num iterations
+			KMeans.main(new String[] {IN_FILE, IN_FILE, OUT_FILE, "123"});
+		} catch(ProgramAbortException pae) {
+			// all good.
+		} catch (Exception e) {
+			e.printStackTrace();
+			Assert.fail("KMeans failed with an exception");
+		}
+		dump(env.getPlan());
+	}
+	
+	@Test
 	public void dumpWebLogAnalysis() {
 		dump(new WebLogAnalysis().getPlan(DEFAULT_PARALLELISM_STRING, IN_FILE, IN_FILE, IN_FILE, OUT_FILE));
 	}