/// <summary>Write the setting to configuration.</summary>
 public static void Write(ReplaceDatanodeOnFailure.Policy policy, bool bestEffort,
                          Configuration conf)
 {
     conf.SetBoolean(DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailureEnableKey, policy
                     != ReplaceDatanodeOnFailure.Policy.Disable);
     conf.Set(DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailurePolicyKey, policy.ToString
                  ());
     conf.SetBoolean(DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailureBestEffortKey
                     , bestEffort);
 }
        private static ReplaceDatanodeOnFailure.Policy GetPolicy(Configuration conf)
        {
            bool enabled = conf.GetBoolean(DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailureEnableKey
                                           , DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailureEnableDefault);

            if (!enabled)
            {
                return(ReplaceDatanodeOnFailure.Policy.Disable);
            }
            string policy = conf.Get(DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailurePolicyKey
                                     , DFSConfigKeys.DfsClientWriteReplaceDatanodeOnFailurePolicyDefault);

            for (int i = 1; i < ReplaceDatanodeOnFailure.Policy.Values().Length; i++)
            {
                ReplaceDatanodeOnFailure.Policy p = ReplaceDatanodeOnFailure.Policy.Values()[i];
                if (Sharpen.Runtime.EqualsIgnoreCase(p.ToString(), policy))
                {
                    return(p);
                }
            }
            throw new HadoopIllegalArgumentException("Illegal configuration value for " + DFSConfigKeys
                                                     .DfsClientWriteReplaceDatanodeOnFailurePolicyKey + ": " + policy);
        }
 public override string ToString()
 {
     return(policy.ToString());
 }