Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to configure the RunJobFlowRequest #9

Merged
merged 1 commit into from
Feb 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/scala/com/bizo/hive/sparkplug/emr/Emr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Emr private(credentials: Option[AWSCredentials]) {

def this(knownCredentials: AWSCredentials) = this(Some(knownCredentials))

def run(flow: JobFlow)(implicit config: ClusterConfig): String = {
def run(flow: JobFlow, configureRequest: RunJobFlowRequest => RunJobFlowRequest = identity)
(implicit config: ClusterConfig): String = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe provide a backwards compatible API here?

def run(flow :JobFlow)(implicit config: ClusterConfig): String = 
  run(flow, identity[RunJobFlowRequest])(config)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point but it is backwards compatible due to the default value (which basically does nothing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh oops didn't see the default value, good call :)

val request = new RunJobFlowRequest(flow.name, toJobFlowInstancesConfig(config, flow.cluster.instances.toSeq, flow.keepAlive, flow.terminationProtection))

request.setAmiVersion(config.amiVersion.orNull)
Expand Down Expand Up @@ -47,7 +48,7 @@ class Emr private(credentials: Option[AWSCredentials]) {

request.setSteps(toStepConfig(flow.steps) asJava)

emr.runJobFlow(request).getJobFlowId
emr.runJobFlow(configureRequest(request)).getJobFlowId
}

private def toJobFlowInstancesConfig(config: ClusterConfig, instances: Seq[InstanceGroup], keepAlive: Boolean, terminationProtection: Boolean): JobFlowInstancesConfig = {
Expand Down Expand Up @@ -112,6 +113,7 @@ class Emr private(credentials: Option[AWSCredentials]) {
}

object Emr {

def apply() = new Emr(EmrJsonCredentials())
def apply(credentials: AWSCredentials) = new Emr(credentials)
def run(flow: JobFlow)(implicit config: ClusterConfig): String = {
Expand Down