Skip to content

Commit

Permalink
extended plan-dump test for KMeans
Browse files Browse the repository at this point in the history
  • Loading branch information
rmetzger committed Jun 18, 2014
1 parent a84f8a1 commit 5484d58
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private void setAsContext() {
}
}

static final class ProgramAbortException extends Error {
public static final class ProgramAbortException extends Error {
private static final long serialVersionUID = 1L;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,14 @@ private static void checkJarFile(File jarfile) throws ProgramInvocationException

// --------------------------------------------------------------------------------------------

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!
Expand All @@ -659,8 +660,12 @@ public String getExecutionPlan() throws Exception {
throw new Client.ProgramAbortException();
}

private void setAsContext() {
public void setAsContext() {
initializeContextEnvironment(this);
}

public Plan getPlan() {
return this.plan;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
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;
Expand Down Expand Up @@ -49,6 +52,23 @@ public void dumpKMeans() {
dump(new KMeansSingleStep().getPlan(DEFAULT_PARALLELISM_STRING, IN_FILE, IN_FILE, OUT_FILE));
}

@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));
Expand Down

0 comments on commit 5484d58

Please sign in to comment.