Ejemplo n.º 1
0
        private void CreateEnvironment()
        {
            var envConfig = new ServiceEnvironmentConfiguration
            {
                DefaultHostName   = "Johnny",
                ConnectionString  = "Data Source=bi_rnd;Initial Catalog=EdgeSystem;Integrated Security=true",
                SP_HostListGet    = "Service_HostList",
                SP_HostRegister   = "Service_HostRegister",
                SP_HostUnregister = "Service_HostUnregister",
                SP_InstanceSave   = "Service_InstanceSave",
                SP_InstanceGet    = "Service_InstanceGet",
                SP_InstanceReset  = "Service_InstanceReset",
                SP_EnvironmentEventListenerListGet    = "Service_EnvironmentEventListenerListGet",
                SP_EnvironmentEventListenerRegister   = "Service_EnvironmentEventListenerRegister",
                SP_EnvironmentEventListenerUnregister = "Service_EnvironmentEventListenerUnregister",
                SP_ServicesExecutionStatistics        = "Service_ExecutionStatistics_GetByPercentile",
                SP_InstanceActiveListGet = "Service_InstanceActiveList_GetByTime"
            };

            _environment = ServiceEnvironment.Open("Scheduler UI", envConfig);
            _listener    = _environment.ListenForEvents(ServiceEnvironmentEventType.ScheduleUpdated);
            _listener.ScheduleUpdated += Listener_ScheduleUpdated;

            //_host = new ServiceExecutionHost(_environment.EnvironmentConfiguration.DefaultHostName, _environment);
        }
        public Scheduler(ServiceEnvironment environment, SchedulerConfiguration configuration)
        {
            Configuration = configuration;

            // set environment and register to env event for scheduling services (from workflow)
            Environment = environment;
            _listener   = environment.ListenForEvents(ServiceEnvironmentEventType.ServiceRequiresScheduling);
            _listener.ServiceRequiresScheduling += Listener_ServiceRequiresScheduling;

            // init base service dictionary
            foreach (var serviceConfig in Configuration.ServiceConfigurationList)
            {
                _serviceBaseConfigurations.Add(serviceConfig.ServiceName, serviceConfig);
            }

            // add services to schedule
            foreach (var service in Configuration.Profiles.SelectMany(profile => profile.Services))
            {
                _serviceConfigurationsToSchedule.Add(service);
            }

            LoadServiceExecutionStatistics();

            LoadRecovery();

            DebugStartupInfo();
        }
        public Scheduler(ServiceEnvironment environment)
        {
            //Load services configurationfile
            string configFileName = EdgeServicesConfiguration.DefaultFileName;

            //if (args.Length > 0 && args[0].StartsWith("/") && args[0].Length > 1)
            //{
            //    configFileName = args[0].Substring(1);
            //}
            EdgeServicesConfiguration.Load(configFileName);

            //wcf for the scheduler to get the profiles

            host = new WebServiceHost(this, new Uri("http://localhost:9000/"));
            WebHttpBinding binding = new WebHttpBinding();

            binding.MaxReceivedMessageSize       = 2147483647;
            binding.MaxBufferSize                = 2147483647;
            binding.MaxBufferPoolSize            = 2147483647;
            binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
            binding.ReaderQuotas.MaxArrayLength  = 2147483647;
            binding.Name = "BLA";



            ServiceEndpoint ep = host.AddServiceEndpoint(typeof(ISchedulerDataService), binding, "http://localhost:9500/");


            DataContractSerializerOperationBehavior be = ep.Contract.Operations[0].Behaviors.Find <DataContractSerializerOperationBehavior>();

            be.MaxItemsInObjectGraph = 2147483647;



            //todo: take care of exeptions, should it be here?
            host.Open();


            Environment = environment;
            environment.ListenForEvents(ServiceEnvironmentEventType.ServiceScheduleRequested);
            environment.ServiceScheduleRequested += new EventHandler <ServiceScheduleRequestedEventArgs>(environment_ServiceScheduleRequested);


            _percentile                      = int.Parse(AppSettings.Get(this, "Percentile"));
            _neededScheduleTimeLine          = TimeSpan.Parse(AppSettings.Get(this, "NeededScheduleTimeLine"));
            _intervalBetweenNewSchedule      = TimeSpan.Parse(AppSettings.Get(this, "IntervalBetweenNewSchedule"));
            _findServicesToRunInterval       = TimeSpan.Parse(AppSettings.Get(this, "FindServicesToRunInterval"));
            _timeToDeleteServiceFromTimeLine = TimeSpan.Parse(AppSettings.Get(this, "DeleteEndedServiceInterval"));
            _executionTimeCashTimeOutAfter   = TimeSpan.Parse(AppSettings.Get(this, "DeleteEndedServiceInterval"));

            LoadServicesFromConfigurationFile();
        }