private void CreateBootstrapActionConfig(String name, String path, List <String> args) { if (String.IsNullOrEmpty(name)) { throw new InvalidOperationException(Resources.E_BootstrapactionNameIsMissing); } if (String.IsNullOrEmpty(path)) { throw new InvalidOperationException(Resources.E_BootstrapactionPathIsMissing); } ScriptBootstrapActionConfig scriptBootstrapAction = new ScriptBootstrapActionConfig(); scriptBootstrapAction.Path = this.settings.FillPlaceHolders(path); scriptBootstrapAction.Args = this.FillPlaceHolders(args); BootstrapActionConfig result = new BootstrapActionConfig(); result.Name = this.settings.FillPlaceHolders(name); result.ScriptBootstrapAction = scriptBootstrapAction; if (this.OnBootstrapActionConfigCreated != null) { this.OnBootstrapActionConfigCreated(this, result); } }
public void VisitBootstrapAction() { //Init args BootstrapAction bootstrapAction = new BootstrapAction(); bootstrapAction.Name = "bootstrap-role:{myRole}"; bootstrapAction.Path = "{myBucket}/lala.sh"; bootstrapAction.Args = new List <string> { "{arg1}", "900" }; //Expectations List <string> expectedArgs = new List <string>() { "1234", "900" }; //Init visitor BuildRequestVisitor visitor = new BuildRequestVisitor(BuildRequestVisitorTest.GetSettings()); VisitorSubscriber visitorSubscriber = new VisitorSubscriber(visitor); //Action bootstrapAction.Accept(visitor); //Verify Assert.AreEqual(1, visitorSubscriber.TotalObjCount, "Unexpected number of objects created"); BootstrapActionConfig actual = visitorSubscriber.bootstrapActionList[0]; Assert.AreEqual("bootstrap-role:SupperSlonic", actual.Name, "Unexpected Name"); Assert.AreEqual("s3://myBucket/lala.sh", actual.ScriptBootstrapAction.Path, "Unexpected ScriptBootstrapAction.Path"); Assert.IsTrue(expectedArgs.SequenceEqual(actual.ScriptBootstrapAction.Args), "Unexpected args list"); }
public void VisitHadoopConfig() { //Init args HadoopConfig hadoopConfig = new HadoopConfig(); hadoopConfig.Args = new List <string> { "{arg1}", "900" }; //Expectations List <string> expectedArgs = new List <string>() { "1234", "900" }; //Init visitor BuildRequestVisitor visitor = new BuildRequestVisitor(BuildRequestVisitorTest.GetSettings()); VisitorSubscriber visitorSubscriber = new VisitorSubscriber(visitor); //Action hadoopConfig.Accept(visitor); //Verify Assert.AreEqual(1, visitorSubscriber.TotalObjCount, "Unexpected number of objects created"); BootstrapActionConfig actual = visitorSubscriber.bootstrapActionList[0]; Assert.AreEqual("Configure Hadoop", actual.Name, "Unexpected Name"); Assert.AreEqual("s3://elasticmapreduce/bootstrap-actions/configure-hadoop", actual.ScriptBootstrapAction.Path, "Unexpected ScriptBootstrapAction.Path"); Assert.IsTrue(expectedArgs.SequenceEqual(actual.ScriptBootstrapAction.Args), "Unexpected args list"); }
public void VisitHBaseConfig() { //Init args HBaseConfig hBaseConfig = new HBaseConfig() { IfStart = true }; hBaseConfig.JarPath = "/home/hadoop/lib/hbase-0.94.7.jar"; hBaseConfig.Args = new List <string>() { "-s", "somearg{arg1}", "-s", "{arg2}" }; //Expectations List <string> expectedConfigArgs = new List <string>() { "-s", "somearg1234", "-s", "6789" }; List <string> expectedStartArgs = new List <string>() { "--start-master" }; //Init settings BuilderSettings settings = BuildRequestVisitorTest.GetSettings(); //Init visitor BuildRequestVisitor visitor = new BuildRequestVisitor(settings); VisitorSubscriber visitorSubscriber = new VisitorSubscriber(visitor); //Action hBaseConfig.Accept(visitor); //Verify Assert.AreEqual(3, visitorSubscriber.TotalObjCount, "Unexpected number of objects created"); // BootstrapAction 1: Install HBase BootstrapActionConfig actualBootstrapAction = visitorSubscriber.bootstrapActionList[0]; Assert.AreEqual("Install HBase", actualBootstrapAction.Name, "Unexpected Name"); Assert.AreEqual("s3://elasticmapreduce/bootstrap-actions/setup-hbase", actualBootstrapAction.ScriptBootstrapAction.Path, "Unexpected ScriptBootstrapAction.Path"); Assert.IsNull(actualBootstrapAction.ScriptBootstrapAction.Args, "Unexpected args list"); // BootstrapAction 2: Configure HBase actualBootstrapAction = visitorSubscriber.bootstrapActionList[1]; Assert.AreEqual("Configure HBase", actualBootstrapAction.Name, "Unexpected Name"); Assert.AreEqual("s3://elasticmapreduce/bootstrap-actions/configure-hbase", actualBootstrapAction.ScriptBootstrapAction.Path, "Unexpected ScriptBootstrapAction.Path"); Assert.IsTrue(expectedConfigArgs.SequenceEqual(actualBootstrapAction.ScriptBootstrapAction.Args), "Unexpected args list"); //Step : Start HBase StepConfig actualStep = visitorSubscriber.stepList[0]; Assert.AreEqual("Start HBase", actualStep.Name, "Unexpected Name"); Assert.AreEqual(ActionOnFailure.TERMINATE_JOB_FLOW, actualStep.ActionOnFailure, "Unexpected ActionOnFailure"); Assert.AreEqual("/home/hadoop/lib/hbase-0.94.7.jar", actualStep.HadoopJarStep.Jar, "Unexpected Jar"); Assert.AreEqual("emr.hbase.backup.Main", actualStep.HadoopJarStep.MainClass, "Unexpected MainClass"); Assert.IsTrue(expectedStartArgs.SequenceEqual(actualStep.HadoopJarStep.Args), "Unexpected args list"); }
private void OnBootstrapActionConfigCreated(object sender, BootstrapActionConfig bootstrapActionConfig) { this.result.BootstrapActions.Add(bootstrapActionConfig); }
void visitor_OnBootstrapActionConfigCreated(object sender, BootstrapActionConfig e) { this.baseCheck(sender); this.bootstrapActionList.Add(e); }