/** * Returns an object which can be used in a RunJobflow call. * @return an object which can be used in a RunJobflow call. */ public BootstrapActionConfig build() { return new BootstrapActionConfig() .withName("Configure Hadoop") .withScriptBootstrapAction(new ScriptBootstrapActionConfig() .withPath("s3://" + bucket + "/bootstrap-actions/configure-hadoop") .withArgs(args)); } }
/** * Constructs a new BootstrapActionConfig object. Callers should use the setter or fluent setter (with...) methods * to initialize any additional object members. * * @param name * The name of the bootstrap action. * @param scriptBootstrapAction * The script run by the bootstrap action. */ public BootstrapActionConfig(String name, ScriptBootstrapActionConfig scriptBootstrapAction) { setName(name); setScriptBootstrapAction(scriptBootstrapAction); }
/** * Create a new run-if bootstrap action which lets you conditionally run bootstrap actions. * @param condition The condition to evaluate, if true the bootstrap action executes. * @param config The bootstrap action to execute in case of successful evaluation. * @return A BootstrapActionConfig to be provided when running a job flow. */ public BootstrapActionConfig newRunIf(String condition, BootstrapActionConfig config) { List<String> args = config.getScriptBootstrapAction().getArgs(); args.add(0, condition); args.add(1, config.getScriptBootstrapAction().getPath()); return new BootstrapActionConfig() .withName("Run If, " + config.getName()) .withScriptBootstrapAction(new ScriptBootstrapActionConfig() .withPath("s3://" + bucket + "/bootstrap-actions/run-if") .withArgs(args)); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getScriptBootstrapAction() == null) ? 0 : getScriptBootstrapAction().hashCode()); return hashCode; }
public BootstrapActionConfig unmarshall(JsonUnmarshallerContext context) throws Exception { BootstrapActionConfig bootstrapActionConfig = new BootstrapActionConfig(); if (context.testExpression("Name", targetDepth)) { context.nextToken(); bootstrapActionConfig.setName(context.getUnmarshaller(String.class).unmarshall(context)); bootstrapActionConfig.setScriptBootstrapAction(ScriptBootstrapActionConfigJsonUnmarshaller.getInstance().unmarshall(context));
private void addCustomBootstrapActionConfig(EmrClusterDefinition emrClusterDefinition, ArrayList<BootstrapActionConfig> bootstrapActions) { // Add Custom bootstrap script support if needed if (!CollectionUtils.isEmpty(emrClusterDefinition.getCustomBootstrapActionAll())) { for (ScriptDefinition scriptDefinition : emrClusterDefinition.getCustomBootstrapActionAll()) { BootstrapActionConfig customActionConfigAll = getBootstrapActionConfig(scriptDefinition.getScriptName(), scriptDefinition.getScriptLocation()); ArrayList<String> argList = new ArrayList<>(); if (!CollectionUtils.isEmpty(scriptDefinition.getScriptArguments())) { for (String argument : scriptDefinition.getScriptArguments()) { // Trim the argument argList.add(argument.trim()); } } // Set arguments to bootstrap action customActionConfigAll.getScriptBootstrapAction().setArgs(argList); bootstrapActions.add(customActionConfigAll); } } }
/** * <p> * The name of the bootstrap action. * </p> * * @param name * The name of the bootstrap action. * @return Returns a reference to this object so that method calls can be chained together. */ public BootstrapActionConfig withName(String name) { setName(name); return this; }
/** * <p> * The script run by the bootstrap action. * </p> * * @param scriptBootstrapAction * The script run by the bootstrap action. * @return Returns a reference to this object so that method calls can be chained together. */ public BootstrapActionConfig withScriptBootstrapAction(ScriptBootstrapActionConfig scriptBootstrapAction) { setScriptBootstrapAction(scriptBootstrapAction); return this; }
/** * Create the BootstrapActionConfig object from the bootstrap script. * * @param scriptDescription bootstrap script name to be displayed. * @param bootstrapScript location of the bootstrap script. * * @return bootstrap action configuration that contains all the bootstrap actions for the given configuration. */ private BootstrapActionConfig getBootstrapActionConfig(String scriptDescription, String bootstrapScript) { // Create the BootstrapActionConfig object BootstrapActionConfig bootstrapConfig = new BootstrapActionConfig(); ScriptBootstrapActionConfig bootstrapConfigScript = new ScriptBootstrapActionConfig(); // Set the bootstrapScript bootstrapConfig.setName(scriptDescription); bootstrapConfigScript.setPath(bootstrapScript); bootstrapConfig.setScriptBootstrapAction(bootstrapConfigScript); // Return the object return bootstrapConfig; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof BootstrapActionConfig == false) return false; BootstrapActionConfig other = (BootstrapActionConfig) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getScriptBootstrapAction() == null ^ this.getScriptBootstrapAction() == null) return false; if (other.getScriptBootstrapAction() != null && other.getScriptBootstrapAction().equals(this.getScriptBootstrapAction()) == false) return false; return true; }
private void addCustomBootstrapActionConfig(EmrClusterDefinition emrClusterDefinition, ArrayList<BootstrapActionConfig> bootstrapActions) { // Add Custom bootstrap script support if needed if (!CollectionUtils.isEmpty(emrClusterDefinition.getCustomBootstrapActionAll())) { for (ScriptDefinition scriptDefinition : emrClusterDefinition.getCustomBootstrapActionAll()) { BootstrapActionConfig customActionConfigAll = getBootstrapActionConfig(scriptDefinition.getScriptName(), scriptDefinition.getScriptLocation()); ArrayList<String> argList = new ArrayList<>(); if (!CollectionUtils.isEmpty(scriptDefinition.getScriptArguments())) { for (String argument : scriptDefinition.getScriptArguments()) { // Trim the argument argList.add(argument.trim()); } } // Set arguments to bootstrap action customActionConfigAll.getScriptBootstrapAction().setArgs(argList); bootstrapActions.add(customActionConfigAll); } } }
/** * <p> * The name of the bootstrap action. * </p> * * @param name * The name of the bootstrap action. * @return Returns a reference to this object so that method calls can be chained together. */ public BootstrapActionConfig withName(String name) { setName(name); return this; }
/** * <p> * The script run by the bootstrap action. * </p> * * @param scriptBootstrapAction * The script run by the bootstrap action. * @return Returns a reference to this object so that method calls can be chained together. */ public BootstrapActionConfig withScriptBootstrapAction(ScriptBootstrapActionConfig scriptBootstrapAction) { setScriptBootstrapAction(scriptBootstrapAction); return this; }
/** * Create the BootstrapActionConfig object from the bootstrap script. * * @param scriptDescription bootstrap script name to be displayed. * @param bootstrapScript location of the bootstrap script. * * @return bootstrap action configuration that contains all the bootstrap actions for the given configuration. */ private BootstrapActionConfig getBootstrapActionConfig(String scriptDescription, String bootstrapScript) { // Create the BootstrapActionConfig object BootstrapActionConfig bootstrapConfig = new BootstrapActionConfig(); ScriptBootstrapActionConfig bootstrapConfigScript = new ScriptBootstrapActionConfig(); // Set the bootstrapScript bootstrapConfig.setName(scriptDescription); bootstrapConfigScript.setPath(bootstrapScript); bootstrapConfig.setScriptBootstrapAction(bootstrapConfigScript); // Return the object return bootstrapConfig; }
/** * Returns an object which can be used in a RunJobflow call. * @return an object which can be used in a RunJobflow call. */ public BootstrapActionConfig build() { if (replace) { args.add("--replace"); } return new BootstrapActionConfig() .withName("Configure Daemons") .withScriptBootstrapAction(new ScriptBootstrapActionConfig() .withPath("s3://" + bucket + "/bootstrap-actions/configure-daemons") .withArgs(args)); } }
/** * Create a new run-if bootstrap action which lets you conditionally run bootstrap actions. * @param condition The condition to evaluate, if true the bootstrap action executes. * @param config The bootstrap action to execute in case of successful evaluation. * @return A BootstrapActionConfig to be provided when running a job flow. */ public BootstrapActionConfig newRunIf(String condition, BootstrapActionConfig config) { List<String> args = config.getScriptBootstrapAction().getArgs(); args.add(0, condition); args.add(1, config.getScriptBootstrapAction().getPath()); return new BootstrapActionConfig() .withName("Run If, " + config.getName()) .withScriptBootstrapAction(new ScriptBootstrapActionConfig() .withPath("s3://" + bucket + "/bootstrap-actions/run-if") .withArgs(args)); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getName() != null) sb.append("Name: ").append(getName()).append(","); if (getScriptBootstrapAction() != null) sb.append("ScriptBootstrapAction: ").append(getScriptBootstrapAction()); sb.append("}"); return sb.toString(); }
/** * Constructs a new BootstrapActionConfig object. Callers should use the setter or fluent setter (with...) methods * to initialize any additional object members. * * @param name * The name of the bootstrap action. * @param scriptBootstrapAction * The script run by the bootstrap action. */ public BootstrapActionConfig(String name, ScriptBootstrapActionConfig scriptBootstrapAction) { setName(name); setScriptBootstrapAction(scriptBootstrapAction); }
private void addDaemonBootstrapActionConfig(EmrClusterDefinition emrClusterDefinition, ArrayList<BootstrapActionConfig> bootstrapActions) { // Add daemon Configuration support if needed if (!CollectionUtils.isEmpty(emrClusterDefinition.getDaemonConfigurations())) { BootstrapActionConfig daemonBootstrapActionConfig = getBootstrapActionConfig(ConfigurationValue.EMR_CONFIGURE_DAEMON.getKey(), configurationHelper.getProperty(ConfigurationValue.EMR_CONFIGURE_DAEMON)); // Add arguments to the bootstrap script ArrayList<String> argList = new ArrayList<>(); for (Parameter daemonConfig : emrClusterDefinition.getDaemonConfigurations()) { argList.add(daemonConfig.getName() + "=" + daemonConfig.getValue()); } // Add the bootstrap action with arguments daemonBootstrapActionConfig.getScriptBootstrapAction().setArgs(argList); bootstrapActions.add(daemonBootstrapActionConfig); } }
/** * Configure a bootstrap action object, given its name, path and arguments. * * @param path - path for the bootstrap action program in S3 * @param name - name of the bootstrap action * @param args - arguments for the bootstrap action * @return configuration data object for one bootstrap action */ private static BootstrapActionConfig configureBootstrapAction( String path, String name, List<String> args ) { ScriptBootstrapActionConfig scriptBootstrapActionConfig = new ScriptBootstrapActionConfig(); BootstrapActionConfig bootstrapActionConfig = new BootstrapActionConfig(); scriptBootstrapActionConfig.setPath( path ); scriptBootstrapActionConfig.setArgs( args ); bootstrapActionConfig.setName( name ); bootstrapActionConfig.setScriptBootstrapAction( scriptBootstrapActionConfig ); return bootstrapActionConfig; }