Skip to content

Commit

Permalink
Added convenience constructor to RemoteExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanEwen committed Jan 28, 2014
1 parent d8fb870 commit 5a242f7
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ public class RemoteExecutor implements PlanExecutor {
private Client client;

private List<String> jarFiles;

public RemoteExecutor(InetSocketAddress inet, List<String> jarFiles) {
this.client = new Client(inet, new Configuration());
this.jarFiles = jarFiles;
}

public RemoteExecutor(String hostname, int port, List<String> jarFiles) {
this(new InetSocketAddress(hostname, port), jarFiles);

public RemoteExecutor(String hostname, int port) {
this(hostname, port, Collections.<String>emptyList());
}

public RemoteExecutor(String hostname, int port, String jarFile) {
this(hostname, port, Collections.singletonList(jarFile));
}
Expand All @@ -50,6 +46,16 @@ public RemoteExecutor(String hostport, String jarFile) {
this(getInetFromHostport(hostport), Collections.singletonList(jarFile));
}

public RemoteExecutor(String hostname, int port, List<String> jarFiles) {
this(new InetSocketAddress(hostname, port), jarFiles);
}

public RemoteExecutor(InetSocketAddress inet, List<String> jarFiles) {
this.client = new Client(inet, new Configuration());
this.jarFiles = jarFiles;
}


public static InetSocketAddress getInetFromHostport(String hostport) {
// from https://stackoverflow.com/questions/2345063/java-common-way-to-validate-and-convert-hostport-to-inetsocketaddress
URI uri;
Expand All @@ -66,10 +72,12 @@ public static InetSocketAddress getInetFromHostport(String hostport) {
return new InetSocketAddress(host, port);
}


public JobExecutionResult executePlanWithJars(JobWithJars p) throws Exception {
return this.client.run(p, true);
}


@Override
public JobExecutionResult executePlan(Plan plan) throws Exception {
JobWithJars p = new JobWithJars(plan, this.jarFiles);
Expand Down

0 comments on commit 5a242f7

Please sign in to comment.