/** * Convert RunJobFlowRequest to name value pairs */ private static IDictionary <string, string> ConvertRunJobFlow(RunJobFlowRequest request) { IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters["Action"] = "RunJobFlow"; if (request.IsSetName()) { parameters["Name"] = request.Name; } if (request.IsSetLogUri()) { parameters["LogUri"] = request.LogUri; } if (request.IsSetAdditionalInfo()) { parameters["AdditionalInfo"] = request.AdditionalInfo; } if (request.IsSetInstances()) { JobFlowInstancesConfig runJobFlowRequestInstances = request.Instances; if (runJobFlowRequestInstances.IsSetMasterInstanceType()) { parameters[String.Concat("Instances", ".", "MasterInstanceType")] = runJobFlowRequestInstances.MasterInstanceType; } if (runJobFlowRequestInstances.IsSetSlaveInstanceType()) { parameters[String.Concat("Instances", ".", "SlaveInstanceType")] = runJobFlowRequestInstances.SlaveInstanceType; } if (runJobFlowRequestInstances.IsSetInstanceCount()) { parameters[String.Concat("Instances", ".", "InstanceCount")] = runJobFlowRequestInstances.InstanceCount.ToString(); } if (runJobFlowRequestInstances.IsSetEc2KeyName()) { parameters[String.Concat("Instances", ".", "Ec2KeyName")] = runJobFlowRequestInstances.Ec2KeyName; } if (runJobFlowRequestInstances.IsSetPlacement()) { PlacementType instancesPlacement = runJobFlowRequestInstances.Placement; if (instancesPlacement.IsSetAvailabilityZone()) { parameters[String.Concat("Instances", ".", "Placement", ".", "AvailabilityZone")] = instancesPlacement.AvailabilityZone; } } if (runJobFlowRequestInstances.IsSetKeepJobFlowAliveWhenNoSteps()) { parameters[String.Concat("Instances", ".", "KeepJobFlowAliveWhenNoSteps")] = runJobFlowRequestInstances.KeepJobFlowAliveWhenNoSteps.ToString().ToLower(); } if (runJobFlowRequestInstances.IsSetHadoopVersion()) { parameters[String.Concat("Instances", ".", "HadoopVersion")] = runJobFlowRequestInstances.HadoopVersion; } } List <StepConfig> runJobFlowRequestStepsList = request.Steps; int runJobFlowRequestStepsListIndex = 1; foreach (StepConfig runJobFlowRequestSteps in runJobFlowRequestStepsList) { if (runJobFlowRequestSteps.IsSetName()) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "Name")] = runJobFlowRequestSteps.Name; } if (runJobFlowRequestSteps.IsSetActionOnFailure()) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "ActionOnFailure")] = runJobFlowRequestSteps.ActionOnFailure; } if (runJobFlowRequestSteps.IsSetHadoopJarStep()) { HadoopJarStepConfig stepsHadoopJarStep = runJobFlowRequestSteps.HadoopJarStep; List <KeyValue> hadoopJarStepPropertiesList = stepsHadoopJarStep.Properties; int hadoopJarStepPropertiesListIndex = 1; foreach (KeyValue hadoopJarStepProperties in hadoopJarStepPropertiesList) { if (hadoopJarStepProperties.IsSetKey()) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "HadoopJarStep", ".", "Properties", ".member.", hadoopJarStepPropertiesListIndex, ".", "Key")] = hadoopJarStepProperties.Key; } if (hadoopJarStepProperties.IsSetValue()) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "HadoopJarStep", ".", "Properties", ".member.", hadoopJarStepPropertiesListIndex, ".", "Value")] = hadoopJarStepProperties.Value; } hadoopJarStepPropertiesListIndex++; } if (stepsHadoopJarStep.IsSetJar()) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "HadoopJarStep", ".", "Jar")] = stepsHadoopJarStep.Jar; } if (stepsHadoopJarStep.IsSetMainClass()) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "HadoopJarStep", ".", "MainClass")] = stepsHadoopJarStep.MainClass; } List <string> hadoopJarStepArgsList = stepsHadoopJarStep.Args; int hadoopJarStepArgsListIndex = 1; foreach (string hadoopJarStepArgs in hadoopJarStepArgsList) { parameters[String.Concat("Steps", ".member.", runJobFlowRequestStepsListIndex, ".", "HadoopJarStep", ".", "Args", ".member.", hadoopJarStepArgsListIndex)] = hadoopJarStepArgs; hadoopJarStepArgsListIndex++; } } runJobFlowRequestStepsListIndex++; } List <BootstrapActionConfig> runJobFlowRequestBootstrapActionsList = request.BootstrapActions; int runJobFlowRequestBootstrapActionsListIndex = 1; foreach (BootstrapActionConfig runJobFlowRequestBootstrapActions in runJobFlowRequestBootstrapActionsList) { if (runJobFlowRequestBootstrapActions.IsSetName()) { parameters[String.Concat("BootstrapActions", ".member.", runJobFlowRequestBootstrapActionsListIndex, ".", "Name")] = runJobFlowRequestBootstrapActions.Name; } if (runJobFlowRequestBootstrapActions.IsSetScriptBootstrapAction()) { ScriptBootstrapActionConfig bootstrapActionsScriptBootstrapAction = runJobFlowRequestBootstrapActions.ScriptBootstrapAction; if (bootstrapActionsScriptBootstrapAction.IsSetPath()) { parameters[String.Concat("BootstrapActions", ".member.", runJobFlowRequestBootstrapActionsListIndex, ".", "ScriptBootstrapAction", ".", "Path")] = bootstrapActionsScriptBootstrapAction.Path; } List <string> scriptBootstrapActionArgsList = bootstrapActionsScriptBootstrapAction.Args; int scriptBootstrapActionArgsListIndex = 1; foreach (string scriptBootstrapActionArgs in scriptBootstrapActionArgsList) { parameters[String.Concat("BootstrapActions", ".member.", runJobFlowRequestBootstrapActionsListIndex, ".", "ScriptBootstrapAction", ".", "Args", ".member.", scriptBootstrapActionArgsListIndex)] = scriptBootstrapActionArgs; scriptBootstrapActionArgsListIndex++; } } runJobFlowRequestBootstrapActionsListIndex++; } return(parameters); }
private static IDictionary <string, string> ConvertRunJobFlow(RunJobFlowRequest request) { IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary["Action"] = "RunJobFlow"; if (request.IsSetName()) { dictionary["Name"] = request.Name; } if (request.IsSetLogUri()) { dictionary["LogUri"] = request.LogUri; } if (request.IsSetAdditionalInfo()) { dictionary["AdditionalInfo"] = request.AdditionalInfo; } if (request.IsSetInstances()) { JobFlowInstancesConfig instances = request.Instances; if (instances.IsSetMasterInstanceType()) { dictionary["Instances" + "." + "MasterInstanceType"] = instances.MasterInstanceType; } if (instances.IsSetSlaveInstanceType()) { dictionary["Instances" + "." + "SlaveInstanceType"] = instances.SlaveInstanceType; } if (instances.IsSetInstanceCount()) { dictionary["Instances" + "." + "InstanceCount"] = instances.InstanceCount.ToString(); } if (instances.IsSetEc2KeyName()) { dictionary["Instances" + "." + "Ec2KeyName"] = instances.Ec2KeyName; } if (instances.IsSetPlacement()) { PlacementType placement = instances.Placement; if (placement.IsSetAvailabilityZone()) { dictionary["Instances" + "." + "Placement" + "." + "AvailabilityZone"] = placement.AvailabilityZone; } } if (instances.IsSetKeepJobFlowAliveWhenNoSteps()) { dictionary["Instances" + "." + "KeepJobFlowAliveWhenNoSteps"] = instances.KeepJobFlowAliveWhenNoSteps.ToString().ToLower(); } if (instances.IsSetHadoopVersion()) { dictionary["Instances" + "." + "HadoopVersion"] = instances.HadoopVersion; } } List <StepConfig> steps = request.Steps; int num = 1; foreach (StepConfig config2 in steps) { if (config2.IsSetName()) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "Name" })] = config2.Name; } if (config2.IsSetActionOnFailure()) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "ActionOnFailure" })] = config2.ActionOnFailure; } if (config2.IsSetHadoopJarStep()) { HadoopJarStepConfig hadoopJarStep = config2.HadoopJarStep; List <KeyValue> properties = hadoopJarStep.Properties; int num2 = 1; foreach (KeyValue value2 in properties) { if (value2.IsSetKey()) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "HadoopJarStep", ".", "Properties", ".member.", num2, ".", "Key" })] = value2.Key; } if (value2.IsSetValue()) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "HadoopJarStep", ".", "Properties", ".member.", num2, ".", "Value" })] = value2.Value; } num2++; } if (hadoopJarStep.IsSetJar()) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "HadoopJarStep", ".", "Jar" })] = hadoopJarStep.Jar; } if (hadoopJarStep.IsSetMainClass()) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "HadoopJarStep", ".", "MainClass" })] = hadoopJarStep.MainClass; } List <string> args = hadoopJarStep.Args; int num3 = 1; foreach (string str in args) { dictionary[string.Concat(new object[] { "Steps", ".member.", num, ".", "HadoopJarStep", ".", "Args", ".member.", num3 })] = str; num3++; } } num++; } List <BootstrapActionConfig> bootstrapActions = request.BootstrapActions; int num4 = 1; foreach (BootstrapActionConfig config4 in bootstrapActions) { if (config4.IsSetName()) { dictionary[string.Concat(new object[] { "BootstrapActions", ".member.", num4, ".", "Name" })] = config4.Name; } if (config4.IsSetScriptBootstrapAction()) { ScriptBootstrapActionConfig scriptBootstrapAction = config4.ScriptBootstrapAction; if (scriptBootstrapAction.IsSetPath()) { dictionary[string.Concat(new object[] { "BootstrapActions", ".member.", num4, ".", "ScriptBootstrapAction", ".", "Path" })] = scriptBootstrapAction.Path; } List <string> list5 = scriptBootstrapAction.Args; int num5 = 1; foreach (string str2 in list5) { dictionary[string.Concat(new object[] { "BootstrapActions", ".member.", num4, ".", "ScriptBootstrapAction", ".", "Args", ".member.", num5 })] = str2; num5++; } } num4++; } return(dictionary); }