You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by do...@apache.org on 2016/03/01 02:56:02 UTC

reef git commit: [REEF-918] Remove deprecated functions in ClrHandlerHelper

Repository: reef
Updated Branches:
  refs/heads/master 94a2ccb91 -> cf79f1b31


[REEF-918] Remove deprecated functions in ClrHandlerHelper

JIRA:
  [REEF-918] https://issues.apache.org/jira/browse/REEF-918

Pull Request:
  Closes #863


Project: http://git-wip-us.apache.org/repos/asf/reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/cf79f1b3
Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/cf79f1b3
Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/cf79f1b3

Branch: refs/heads/master
Commit: cf79f1b310a3906dbc7fae47ddbaf08e04a50218
Parents: 94a2ccb
Author: Andrew Chung <af...@gmail.com>
Authored: Fri Feb 26 14:54:25 2016 -0800
Committer: Dongjoon Hyun <do...@apache.org>
Committed: Mon Feb 29 17:43:01 2016 -0800

----------------------------------------------------------------------
 .../Bridge/ClrHandlerHelper.cs                  | 78 +-------------------
 .../Bridge/CommandLineArguments.cs              |  1 -
 .../HelloAllocatedEvaluatorHandler.cs           | 13 ++--
 .../KMeans/KMeansDriverHandlers.cs              |  8 +-
 4 files changed, 14 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/reef/blob/cf79f1b3/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs
index aa4aa4b..690b3e6 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrHandlerHelper.cs
@@ -38,8 +38,7 @@ namespace Org.Apache.REEF.Driver.Bridge
         /// <summary>
         /// The set of REEF assemblies required for the Driver.
         /// </summary>
-        [Obsolete("Deprecated in 0.14. Will be made internal in 0.15.")]
-        public static string[] ReefAssemblies
+        internal static string[] ReefAssemblies
         {
             get
             {
@@ -68,8 +67,7 @@ namespace Org.Apache.REEF.Driver.Bridge
         /// </summary>
         /// <param name="handler">The EventHandler</param>
         /// <returns>The InterOp handle</returns>
-        [Obsolete("Deprecated in 0.14. Will be removed in 0.15.")]
-        public static ulong CreateHandler(object handler)
+        internal static ulong CreateHandler(object handler)
         {
             GCHandle gc = GCHandle.Alloc(handler);
             IntPtr intPtr = GCHandle.ToIntPtr(gc);
@@ -89,85 +87,15 @@ namespace Org.Apache.REEF.Driver.Bridge
         }
 
         /// <summary>
-        /// Sets the memory granularity in megabytes for the Evaluator Descriptors.
-        /// </summary>
-        /// <param name="granularity">The memory granularity in megabytes</param>
-        [Obsolete("Deprecated in 0.14. Will be removed in 0.15.")]
-        public static void SetMemoryGranuality(int granularity)
-        {
-            if (granularity <= 0)
-            {
-                var e = new ArgumentException("Granularity must be a positive value, provided: " + granularity);
-                Exceptions.Throw(e, LOGGER);
-            }
-            MemoryGranularity = granularity;
-        }
-
-        /// <summary>
         /// Returns the null handle not used on the Java side (i.e. 0).
         /// </summary>
         /// <returns>The null handle</returns>
-        [Obsolete("Deprecated in 0.14. Will be removed in 0.15.")]
-        public static ulong CreateNullHandler()
+        internal static ulong CreateNullHandler()
         {
             return Constants.NullHandler;
         }
 
         /// <summary>
-        /// Gets the command line arguments as specified in <see cref="DriverBridgeConfigurationOptions.ArgumentSets"/>.
-        /// </summary>
-        /// <returns>The set of command line arguments</returns>
-        [Obsolete("Deprecated in 0.14. Will be removed in 0.15. Inject the CommandLineArguments in your Handler instead.")]
-        public static ISet<string> GetCommandLineArguments()
-        {
-            using (LOGGER.LogFunction("ClrHandlerHelper::GetCommandLineArguments"))
-            {
-                CommandLineArguments arguments;
-                try
-                {                       
-                    arguments = BridgeConfigurationProvider.GetBridgeInjector(null).GetInstance<CommandLineArguments>();
-                }
-                catch (InjectionException e)
-                {
-                    const string error = "Cannot inject command line arguments from driver bridge configuration.";
-                    Exceptions.CaughtAndThrow(e, Level.Error, error, LOGGER);
-                    throw;
-                }
-                return arguments.Arguments;
-            }
-        }
-
-        /// <summary>
-        /// Allows additional Java classes to be included into the classpath by the user.
-        /// Generates a file named <see cref="Constants.GlobalUserSuppliedJavaLibraries"/> in the 
-        /// executing directory containing classpath information.
-        /// </summary>
-        /// <param name="classPaths">classpaths to the Java classes</param>
-        [Obsolete("Deprecated in 0.14. Will be removed in 0.15.")]
-        public static void SupplyAdditionalClassPath(params string[] classPaths)
-        {
-            var path = Path.Combine(Directory.GetCurrentDirectory(), Constants.GlobalUserSuppliedJavaLibraries);
-            File.WriteAllText(path, string.Join(",", classPaths));
-        }
-
-        /// <summary>
-        /// Generates the class hierarchy binary to the current directory into a file named
-        /// <see cref="Constants.ClassHierarchyBin"/>.
-        /// </summary>
-        /// <param name="clrDlls">The set of DLLs generating the class hierarchy</param>
-        [Obsolete("Deprecated in 0.14. Will be removed in 0.15.")]
-        public static void GenerateClassHierarchy(ISet<string> clrDlls)
-        {
-            using (LOGGER.LogFunction("ClrHandlerHelper::GenerateClassHierarchy"))
-            {
-                IClassHierarchy ns = TangFactory.GetTang().GetClassHierarchy(clrDlls.ToArray());
-                ProtocolBufferClassHierarchy.Serialize(Constants.ClassHierarchyBin, ns);
-
-                LOGGER.Log(Level.Info, "Class hierarchy written to [{0}].", Path.Combine(Directory.GetCurrentDirectory(), Constants.ClassHierarchyBin));
-            }
-        }
-
-        /// <summary>
         /// Gets the list of assemblies needed for the REEF driver.
         /// </summary>
         /// <returns>A whitespace separated string consisting of all the required driver assemblies</returns>

http://git-wip-us.apache.org/repos/asf/reef/blob/cf79f1b3/lang/cs/Org.Apache.REEF.Driver/Bridge/CommandLineArguments.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/CommandLineArguments.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/CommandLineArguments.cs
index 1fa287a..f75edaf 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/CommandLineArguments.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/CommandLineArguments.cs
@@ -15,7 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-using System;
 using System.Collections.Generic;
 using Org.Apache.REEF.Tang.Annotations;
 

http://git-wip-us.apache.org/repos/asf/reef/blob/cf79f1b3/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloAllocatedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloAllocatedEvaluatorHandler.cs b/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloAllocatedEvaluatorHandler.cs
index 944fa57..429eb8b 100644
--- a/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloAllocatedEvaluatorHandler.cs
+++ b/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloAllocatedEvaluatorHandler.cs
@@ -42,9 +42,12 @@ namespace Org.Apache.REEF.Examples.AllHandlers
     /// </summary>
     public class HelloAllocatedEvaluatorHandler : IObserver<IAllocatedEvaluator>
     {
+        private readonly ISet<string> _arguments;
+        
         [Inject]
-        private HelloAllocatedEvaluatorHandler()
+        private HelloAllocatedEvaluatorHandler(CommandLineArguments arguments)
         {
+            _arguments = arguments.Arguments;
         }
 
         /// <summary>
@@ -55,16 +58,14 @@ namespace Org.Apache.REEF.Examples.AllHandlers
         {
             string control = string.Empty;
 
-            ISet<string> arguments = ClrHandlerHelper.GetCommandLineArguments();
-
-            if (arguments != null && arguments.Any())
+            if (_arguments.Any())
             {
-                foreach (string argument in arguments)
+                foreach (string argument in _arguments)
                 {
                     Console.WriteLine("testing argument: " + argument);
                 }
 
-                control = arguments.Last();
+                control = _arguments.Last();
             }
 
             IEvaluatorDescriptor descriptor = allocatedEvaluator.GetEvaluatorDescriptor();

http://git-wip-us.apache.org/repos/asf/reef/blob/cf79f1b3/lang/cs/Org.Apache.REEF.Examples/MachineLearning/KMeans/KMeansDriverHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Examples/MachineLearning/KMeans/KMeansDriverHandlers.cs b/lang/cs/Org.Apache.REEF.Examples/MachineLearning/KMeans/KMeansDriverHandlers.cs
index a2ca17e..e0e75f8 100644
--- a/lang/cs/Org.Apache.REEF.Examples/MachineLearning/KMeans/KMeansDriverHandlers.cs
+++ b/lang/cs/Org.Apache.REEF.Examples/MachineLearning/KMeans/KMeansDriverHandlers.cs
@@ -66,14 +66,14 @@ namespace Org.Apache.REEF.Examples.MachineLearning.KMeans
         private readonly IEvaluatorRequestor _evaluatorRequestor;
 
         [Inject]
-        public KMeansDriverHandlers(
+        private KMeansDriverHandlers(
             [Parameter(typeof(NumPartitions))] int numPartitions, 
             GroupCommDriver groupCommDriver,
-            IEvaluatorRequestor evaluatorRequestor)
+            IEvaluatorRequestor evaluatorRequestor,
+            CommandLineArguments arguments)
         {
             _executionDirectory = Path.Combine(Directory.GetCurrentDirectory(), Constants.KMeansExecutionBaseDirectory, Guid.NewGuid().ToString("N").Substring(0, 4));
-            ISet<string> arguments = ClrHandlerHelper.GetCommandLineArguments();
-            string dataFile = arguments.Single(a => a.StartsWith("DataFile", StringComparison.Ordinal)).Split(':')[1];
+            string dataFile = arguments.Arguments.Single(a => a.StartsWith("DataFile", StringComparison.Ordinal)).Split(':')[1];
             DataVector.ShuffleDataAndGetInitialCentriods(
                 Path.Combine(Directory.GetCurrentDirectory(), "reef", "global", dataFile),
                 numPartitions,