Exemplo n.º 1
0
        public KMeansDriverHandlers(
            [Parameter(typeof(NumPartitions))] int numPartitions,
            GroupCommDriver groupCommDriver,
            IEvaluatorRequestor evaluatorRequestor)
        {
            _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];

            DataVector.ShuffleDataAndGetInitialCentriods(
                Path.Combine(Directory.GetCurrentDirectory(), "reef", "global", dataFile),
                numPartitions,
                _clustersNumber,
                _executionDirectory);

            _totalEvaluators = numPartitions + 1;

            _groupCommDriver    = groupCommDriver;
            _evaluatorRequestor = evaluatorRequestor;

            _centroidCodecConf = CodecToStreamingCodecConfiguration <Centroids> .Conf
                                 .Set(CodecConfiguration <Centroids> .Codec, GenericType <CentroidsCodec> .Class)
                                 .Build();

            IConfiguration dataConverterConfig1 = PipelineDataConverterConfiguration <Centroids> .Conf
                                                  .Set(PipelineDataConverterConfiguration <Centroids> .DataConverter, GenericType <DefaultPipelineDataConverter <Centroids> > .Class)
                                                  .Build();

            _controlMessageCodecConf = CodecToStreamingCodecConfiguration <ControlMessage> .Conf
                                       .Set(CodecConfiguration <ControlMessage> .Codec, GenericType <ControlMessageCodec> .Class)
                                       .Build();

            IConfiguration dataConverterConfig2 = PipelineDataConverterConfiguration <ControlMessage> .Conf
                                                  .Set(PipelineDataConverterConfiguration <ControlMessage> .DataConverter, GenericType <DefaultPipelineDataConverter <ControlMessage> > .Class)
                                                  .Build();

            _processedResultsCodecConf = CodecToStreamingCodecConfiguration <ProcessedResults> .Conf
                                         .Set(CodecConfiguration <ProcessedResults> .Codec, GenericType <ProcessedResultsCodec> .Class)
                                         .Build();

            IConfiguration reduceFunctionConfig = ReduceFunctionConfiguration <ProcessedResults> .Conf
                                                  .Set(ReduceFunctionConfiguration <ProcessedResults> .ReduceFunction, GenericType <KMeansMasterTask.AggregateMeans> .Class)
                                                  .Build();

            IConfiguration dataConverterConfig3 = PipelineDataConverterConfiguration <ProcessedResults> .Conf
                                                  .Set(PipelineDataConverterConfiguration <ProcessedResults> .DataConverter, GenericType <DefaultPipelineDataConverter <ProcessedResults> > .Class)
                                                  .Build();

            _commGroup = _groupCommDriver.DefaultGroup
                         .AddBroadcast <Centroids>(Constants.CentroidsBroadcastOperatorName, Constants.MasterTaskId, TopologyTypes.Flat, dataConverterConfig1)
                         .AddBroadcast <ControlMessage>(Constants.ControlMessageBroadcastOperatorName, Constants.MasterTaskId, TopologyTypes.Flat, dataConverterConfig2)
                         .AddReduce <ProcessedResults>(Constants.MeansReduceOperatorName, Constants.MasterTaskId, TopologyTypes.Flat, reduceFunctionConfig, dataConverterConfig3)
                         .Build();

            _groupCommTaskStarter = new TaskStarter(_groupCommDriver, _totalEvaluators);
        }
Exemplo n.º 2
0
        private void CreateClassHierarchy()
        {
            HashSet <string> clrDlls = new HashSet <string>();

            clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
            clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
            clrDlls.Add(typeof(MessageTask).Assembly.GetName().Name);

            ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
        }
        private void CreateClassHierarchy()
        {
            HashSet <string> clrDlls = new HashSet <string>();

            clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
            clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
            clrDlls.Add(typeof(BroadcastReduceDriver).Assembly.GetName().Name);
            clrDlls.Add(typeof(INameClient).Assembly.GetName().Name);
            clrDlls.Add(typeof(INetworkService <>).Assembly.GetName().Name);
            ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
        }
Exemplo n.º 4
0
        public static void Run(HashSet <string> appDlls, IConfiguration driverBridgeConfig, DriverSubmissionSettings driverSubmissionSettings, string reefJar = Constants.BridgeJarFileName, string runCommand = "run.cmd", string clrFolder = ".", string className = Constants.BridgeLaunchClass)
        {
            using (LOGGER.LogFunction("ClrHandlerHelper::Run"))
            {
                if (driverSubmissionSettings.Submit)
                {
                    ClrHandlerHelper.CopyDllsToAppDirectory(appDlls);
                    UpdateJarFileWithAssemblies(reefJar);
                }

                using (LOGGER.LogScope("ClrHandlerHelper::serialize driverBridgeConfig to clrRuntimeConfigFile"))
                {
                    string clrRuntimeConfigFile = Path.Combine(clrFolder, Constants.DriverBridgeConfiguration);
                    new AvroConfigurationSerializer().ToFile(driverBridgeConfig, clrRuntimeConfigFile);
                    LOGGER.Log(Level.Info, "CLR driver bridge configurations written to " + clrRuntimeConfigFile);
                }

                ProcessStartInfo startInfo = new ProcessStartInfo();
                if (driverSubmissionSettings.RunOnYarn)
                {
                    startInfo.FileName  = runCommand;
                    startInfo.Arguments = className + " " + clrFolder +
                                          driverSubmissionSettings.ToComamndLineArguments();
                }
                else
                {
                    startInfo.FileName = GetJavaBinary();
                    string loggingPrefix = string.Empty;
                    if (driverSubmissionSettings.JavaLogLevel == JavaLoggingSetting.VERBOSE_TO_CLR)
                    {
                        loggingPrefix = Constants.JavaToCLRLoggingConfig + " ";
                    }
                    else if (driverSubmissionSettings.JavaLogLevel == JavaLoggingSetting.VERBOSE)
                    {
                        loggingPrefix = Constants.JavaVerboseLoggingConfig + " ";
                    }
                    startInfo.Arguments = loggingPrefix + @"-classpath " + reefJar + " " + Constants.BridgeLaunchClass +
                                          " " + clrFolder + " " + driverSubmissionSettings.ToComamndLineArguments();
                }
                startInfo.RedirectStandardOutput = true;
                startInfo.UseShellExecute        = false;
                startInfo.CreateNoWindow         = false;
                LOGGER.Log(Level.Info, "Executing\r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
                using (Process process = Process.Start(startInfo))
                {
                    process.WaitForExit();
                }
            }
        }
Exemplo n.º 5
0
        public IList <ulong> GetHandlers()
        {
            ulong[] handlers = Enumerable.Repeat(Constants.NullHandler, Constants.HandlersNumber).ToArray();

            // initiate Evaluator Requestor handler
            _evaluatorRequestorHandler = new ClrSystemHandler <IEvaluatorRequestor>();
            handlers[Constants.Handlers[Constants.EvaluatorRequestorHandler]] = ClrHandlerHelper.CreateHandler(_evaluatorRequestorHandler);
            Console.WriteLine("_evaluatorRequestorHandler initiated");
            _evaluatorRequestorHandler.Subscribe(new RetainedEvalEvaluatorRequestorHandler());

            // initiate Allocated Evaluator handler
            _allocatedEvaluatorHandler = new ClrSystemHandler <IAllocatedEvaluator>();
            handlers[Constants.Handlers[Constants.AllocatedEvaluatorHandler]] = ClrHandlerHelper.CreateHandler(_allocatedEvaluatorHandler);
            Console.WriteLine("_allocatedEvaluatorHandler initiated");
            _allocatedEvaluatorHandler.Subscribe(new RetainedEvalAllocatedEvaluatorHandler());

            // initiate Active Context handler
            _activeContextHandler = new ClrSystemHandler <IActiveContext>();
            handlers[Constants.Handlers[Constants.ActiveContextHandler]] = ClrHandlerHelper.CreateHandler(_activeContextHandler);
            Console.WriteLine("_activeContextHandler initiated");
            _activeContextHandler.Subscribe(new RetainedEvalActiveContextHandler());

            return(handlers);
        }
Exemplo n.º 6
0
        public static void UpdateJarFileWithAssemblies(string reefJar)
        {
            using (LOGGER.LogFunction("ClrHandlerHelper::UpdateJarFileWithAssemblies"))
            {
                string assembliesList = ClrHandlerHelper.GetAssembliesListForReefDriverApp();
                if (!File.Exists(reefJar))
                {
                    throw new InvalidOperationException("cannot find reef jar file: " + reefJar);
                }
                ProcessStartInfo startInfo = new ProcessStartInfo()
                {
                    FileName  = GetJarBinary(),
                    Arguments = @"uf " + reefJar + " " + assembliesList,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    CreateNoWindow         = true
                };

                LOGGER.Log(Level.Info, "updating jar file with \r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
                using (Process process = Process.Start(startInfo))
                {
                    StreamReader outReader   = process.StandardOutput;
                    StreamReader errorReader = process.StandardError;
                    string       output      = outReader.ReadToEnd();
                    string       error       = errorReader.ReadToEnd();
                    process.WaitForExit();
                    if (process.ExitCode != 0)
                    {
                        throw new InvalidOperationException("Failed to update jar file with stdout :" + output +
                                                            "and stderr:" + error);
                    }
                }
                LOGGER.Log(Level.Info, "jar file updated.");
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Generates the class hieararchy file
 /// </summary>
 /// <param name="value"></param>
 public void OnNext(IDriverStarted value)
 {
     ClrHandlerHelper.GenerateClassHierarchy(GetAssembliesInGlobalFolder());
 }
        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
        {
            string control = string.Empty;

            ISet <string> arguments = ClrHandlerHelper.GetCommandLineArguments();

            if (arguments != null && arguments.Any())
            {
                foreach (string argument in arguments)
                {
                    Console.WriteLine("testing argument: " + argument);
                }

                control = arguments.Last();
            }

            IEvaluatorDescriptor descriptor = allocatedEvaluator.GetEvaluatorDescriptor();

            IConfiguration serviceConfiguration = ServiceConfiguration.ConfigurationModule
                                                  .Set(ServiceConfiguration.Services, GenericType <HelloService> .Class)
                                                  .Build();

            IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule
                                                  .Set(ContextConfiguration.Identifier, "bridgeHelloCLRContextId_" + Guid.NewGuid().ToString("N"))
                                                  .Build();

            IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
                                               .Set(TaskConfiguration.Identifier, "bridgeHelloCLRTaskId_" + Guid.NewGuid().ToString("N"))
                                               .Set(TaskConfiguration.Task, GenericType <HelloTask> .Class)
                                               .Set(TaskConfiguration.OnMessage, GenericType <HelloTask.HelloDriverMessageHandler> .Class)
                                               .Set(TaskConfiguration.OnSendMessage, GenericType <HelloTaskMessage> .Class)
                                               .Build();

            IConfiguration mergedTaskConfiguration = taskConfiguration;

            if (allocatedEvaluator.NameServerInfo != null)
            {
                IPEndPoint nameServerEndpoint = NetUtilities.ParseIpEndpoint(allocatedEvaluator.NameServerInfo);

                IConfiguration nameClientConfiguration = TangFactory.GetTang().NewConfigurationBuilder(
                    NamingConfiguration.ConfigurationModule
                    .Set(NamingConfiguration.NameServerAddress, nameServerEndpoint.Address.ToString())
                    .Set(NamingConfiguration.NameServerPort,
                         nameServerEndpoint.Port.ToString(CultureInfo.InvariantCulture))
                    .Build())
                                                         .BindImplementation(GenericType <INameClient> .Class,
                                                                             GenericType <NameClient> .Class)
                                                         .Build();

                mergedTaskConfiguration = Configurations.Merge(taskConfiguration, nameClientConfiguration);
            }

            string ipAddress = descriptor.NodeDescriptor.InetSocketAddress.Address.ToString();
            int    port      = descriptor.NodeDescriptor.InetSocketAddress.Port;
            string hostName  = descriptor.NodeDescriptor.HostName;

            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Alloated evaluator {0} with ip {1}:{2}. Hostname is {3}", allocatedEvaluator.Id, ipAddress, port, hostName));
            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Evaluator is assigned with {0} MB of memory and {1} cores.", descriptor.Memory, descriptor.VirtualCore));

            if (control.Equals("submitContext", StringComparison.OrdinalIgnoreCase))
            {
                allocatedEvaluator.SubmitContext(contextConfiguration);
            }
            else if (control.Equals("submitContextAndServiceAndTask", StringComparison.OrdinalIgnoreCase))
            {
                allocatedEvaluator.SubmitContextAndServiceAndTask(contextConfiguration, serviceConfiguration, mergedTaskConfiguration);
            }
            else
            {
                // default behavior
                allocatedEvaluator.SubmitContextAndTask(contextConfiguration, mergedTaskConfiguration);
            }
        }