示例#1
0
        private void ProcessNewEvaluator()
        {
            _evaluatorDescriptor = Clr2Java.GetEvaluatorDescriptor();
            lock (EvaluatorRequestor.Evaluators)
            {
                foreach (KeyValuePair <string, IEvaluatorDescriptor> pair in EvaluatorRequestor.Evaluators)
                {
                    if (pair.Value.Equals(_evaluatorDescriptor))
                    {
                        string key = pair.Key;
                        EvaluatorRequestor.Evaluators.Remove(key);
                        string assignedId = key.Substring(0, key.LastIndexOf('_'));
                        string message    = string.Format(
                            CultureInfo.InvariantCulture,
                            "Received evalautor [{0}] of memory {1}MB that matches request of {2}MB with batch id [{3}].",
                            Id,
                            _evaluatorDescriptor.Memory,
                            pair.Value.Memory,
                            assignedId);

                        LOGGER.Log(Level.Verbose, message);
                        EvaluatorBatchId = assignedId;
                        break;
                    }
                }
            }
        }
示例#2
0
        public void OnNext(IActiveContext activeContext)
        {
            Console.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Active context {0} received from evaluator {1}",
                    activeContext.Id,
                    activeContext.EvaluatorId));

            IEvaluatorDescriptor evaluatorDescriptor = activeContext.EvaluatorDescriptor;
            string ipAddress = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Address.ToString();
            int    port      = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Port;
            string hostName  = evaluatorDescriptor.NodeDescriptor.HostName;

            Console.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "The running evaluator is assigned with {0} MB of memory and is running at ip: {1} and port {2}, with hostname {3}",
                    evaluatorDescriptor.Memory,
                    ipAddress,
                    port,
                    hostName));

            IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
                                               .Set(TaskConfiguration.Identifier, "bridgeCLRHelloTask_" + DateTime.Now.Ticks)
                                               .Set(TaskConfiguration.Task, GenericType <HelloTask> .Class)
                                               .Set(TaskConfiguration.OnMessage, GenericType <HelloTask.HelloDriverMessageHandler> .Class)
                                               .Set(TaskConfiguration.OnSendMessage, GenericType <HelloTaskMessage> .Class)
                                               .Build();

            activeContext.SubmitTask(taskConfiguration);
        }
示例#3
0
 public BridgeAllocatedEvaluator(
     string id,
     IDriverServiceClient driverServiceClient,
     IEvaluatorDescriptor evaluatorDescriptor)
 {
     Id = id;
     _driverServiceClient = driverServiceClient;
     _evaluatorDescriptor = evaluatorDescriptor;
 }
示例#4
0
        private bool EquivalentMemory(IEvaluatorDescriptor other)
        {
            var granularity = ClrHandlerHelper.MemoryGranularity == 0
                ? Constants.DefaultMemoryGranularity
                : ClrHandlerHelper.MemoryGranularity;
            var m1 = (Memory - 1) / granularity;
            var m2 = (other.Memory - 1) / granularity;

            return(m1 == m2);
        }
示例#5
0
 public BridgeClosedContext(
     string id,
     string evaluatorId,
     Optional <string> parentId,
     IEvaluatorDescriptor evaluatorDescriptor,
     IActiveContext parentContext)
 {
     Id                  = id;
     EvaluatorId         = evaluatorId;
     ParentId            = parentId;
     EvaluatorDescriptor = evaluatorDescriptor;
     ParentContext       = parentContext;
 }
示例#6
0
 public BridgeActiveContext(
     IDriverServiceClient driverServiceClient,
     string id,
     string evaluatorId,
     Optional <string> parentId,
     IEvaluatorDescriptor evaluatorDescriptor)
 {
     _driverServiceClient = driverServiceClient;
     Id                  = id;
     EvaluatorId         = evaluatorId;
     ParentId            = parentId;
     EvaluatorDescriptor = evaluatorDescriptor;
 }
示例#7
0
        public BridgeFailedContext(
            string id,
            string evaluatorId,
            IEvaluatorDescriptor evaluatorDescriptor,
            Optional <IActiveContext> parentContext)
        {
            Id          = id;
            EvaluatorId = evaluatorId;
            ParentId    = Optional <string> .OfNullable(parentContext.OrElse(null)?.Id);

            EvaluatorDescriptor = evaluatorDescriptor;
            ParentContext       = parentContext;
        }
        /// <summary>
        /// It is called when receiving an active context
        /// </summary>
        /// <param name="activeContext"></param>
        public void OnNext(IActiveContext activeContext)
        {
            Console.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Active context {0} received after driver restart, from evaluator {1}",
                    activeContext.Id,
                    activeContext.EvaluatorId));

            IEvaluatorDescriptor evaluatorDescriptor = activeContext.EvaluatorDescriptor;
            string ipAddress = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Address.ToString();
            int    port      = evaluatorDescriptor.NodeDescriptor.InetSocketAddress.Port;
            string hostName  = evaluatorDescriptor.NodeDescriptor.HostName;

            Console.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "The running evaluator allocated by previous driver is assigned with {0} MB of memory and is running at ip: {1} and port {2}, with hostname {3}",
                    evaluatorDescriptor.Memory,
                    ipAddress,
                    port,
                    hostName));
        }
示例#9
0
 private bool EquivalentMemory(IEvaluatorDescriptor other)
 {
     var granularity = ClrHandlerHelper.MemoryGranularity == 0
         ? Constants.DefaultMemoryGranularity
         : ClrHandlerHelper.MemoryGranularity;
     var m1 = (Memory - 1) / granularity;
     var m2 = (other.Memory - 1) / granularity;
     return m1 == m2;
 }
        /// <summary>
        /// This method create Service/context/task configuration and submit them to the allocatedEvaluator
        /// </summary>
        /// <param name="allocatedEvaluator"></param>
        public void OnNext(IAllocatedEvaluator allocatedEvaluator)
        {
            string control = string.Empty;

            if (_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);
            }
        }
        private void ProcessNewEvaluator()
        {
            _evaluatorDescriptor = Clr2Java.GetEvaluatorDescriptor();
            lock (EvaluatorRequestor.Evaluators)
            {
                foreach (KeyValuePair<string, IEvaluatorDescriptor> pair in EvaluatorRequestor.Evaluators)
                {
                    if (pair.Value.Equals(_evaluatorDescriptor))
                    {
                        var key = pair.Key;
                        EvaluatorRequestor.Evaluators.Remove(key);
                        var assignedId = key.Substring(0, key.LastIndexOf(EvaluatorRequestor.BatchIdxSeparator));

                        LOGGER.Log(Level.Verbose, "Received evaluator [{0}] of memory {1}MB that matches request of {2}MB with batch id [{3}].", 
                            Id, _evaluatorDescriptor.Memory, pair.Value.Memory, assignedId);
                        EvaluatorBatchId = assignedId;
                        break;
                    }
                }
            }
        }
示例#12
0
 private void ProcessNewEvaluator()
 {
     _evaluatorDescriptor = Clr2Java.GetEvaluatorDescriptor();
 }