/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Amazon.Runtime.Internal.Util;
#pragma warning disable 1591
namespace Amazon.ElasticMapReduce.Model
{
///
/// List of Hadoop daemons which can be configured.
///
public enum Daemon
{
NameNode,
DataNode,
JobTracker,
TaskTracker,
Client
}
public class ConfigureDaemons
{
List args = new List();
readonly string bucket;
bool replace = false;
internal ConfigureDaemons(string bucket)
{
this.bucket = bucket;
}
///
/// Set the heap size of a daemon.
///
/// The deamon to configure.
/// The requested heap size of the daemon.
public void AddHeapSize(Daemon daemon, int megabytes)
{
args.Add("--" + daemon.ToString().ToLowerInvariant() + "-heap-size=" + megabytes);
}
///
/// Specify additional Java opts to be included when the daemon starts.
///
/// The daemon to add opts to.
/// Additional Java command line arguments.
public void AddOpts(Daemon daemon, String opts)
{
args.Add("--" + daemon.ToString().ToLowerInvariant() + "-opts=\"" + opts + "\"");
}
///
/// Replace the existing hadoop-user-env.sh file if it exists.
///
public bool Replace
{
get { return this.replace; }
set { this.replace = value; }
}
///
/// Returns an object which can be used in a RunJobflow call.
///
/// an object which can be used in a RunJobflow call.
public BootstrapActionConfig Build()
{
if (replace)
{
args.Add("--replace");
}
return new BootstrapActionConfig
{
Name = "Configure Daemons",
ScriptBootstrapAction = new ScriptBootstrapActionConfig
{
Path = string.Format(CultureInfo.InvariantCulture, "s3://{0}/bootstrap-actions/configure-daemons", bucket),
Args = args
}
};
}
}
}