Ejemplo n.º 1
0
 public DerefResults( IWorker worker, IList<IWorker> workerList )
 {
     _worker = worker;
     _workerList = workerList;
     Debug.Assert( _worker == null || _workerList == null );
     Debug.Assert( _workerList == null || _workerList.Count > 0 );
 }
Ejemplo n.º 2
0
 public Scheduler(IPluginFinder plugins, IHeart heart, IWorker worker, IErrorNotifier errorHandler)
 {
     _actions = new List<ScheduledAction>(InstantiateActions(plugins));
     _heart = heart;
     _worker = worker;
     _errorHandler = errorHandler;
 }
Ejemplo n.º 3
0
        public ContentChangeTracker(IIndexer indexer, IPersister persister, IWorker worker, ConnectionMonitor connection, IErrorNotifier errors, DatabaseSection config)
        {
            this.indexer = indexer;
            this.persister = persister;
            this.worker = worker;
            this.errors = errors;
            this.async = config.Search.AsyncIndexing;
            this.handleErrors = config.Search.HandleErrors;

            RetryInterval = TimeSpan.FromMinutes(2);

            if(config.Search.Enabled)
            {
                connection.Online += delegate
                {
                    persister.ItemSaved += persister_ItemSaved;
                    persister.ItemMoving += persister_ItemMoving;
                    persister.ItemMoved += persister_ItemMoved;
                    persister.ItemCopied += persister_ItemCopied;
                    persister.ItemDeleted += persister_ItemDeleted;
                };
                connection.Offline += delegate
                {
                    persister.ItemSaved -= persister_ItemSaved;
                    persister.ItemMoving -= persister_ItemMoving;
                    persister.ItemMoved -= persister_ItemMoved;
                    persister.ItemCopied -= persister_ItemCopied;
                    persister.ItemDeleted -= persister_ItemDeleted;
                };
            }
        }
Ejemplo n.º 4
0
        public void Start()
        {
            // load the agent info
            Log.Debug("Loading agent context");
            AgentContext.Load();

            if (AgentContext.Current == null)
            {
                throw new ApplicationException("Agent configuration could not be loaded");
            }
            if (string.IsNullOrEmpty(AgentContext.Current.ServerKey))
            {
                throw new ApplicationException("Agent server key not available");
            }

            // load workers
            Log.Debug("Loading agent worker threads");
            MetricsWorker = DependencyRegistry.Resolve<MetricsWorker>();
            DiscoveryWorker = DependencyRegistry.Resolve<DiscoveryWorker>();
            SyncWorker = DependencyRegistry.Resolve<SyncWorker>();

            // initialize  workers
            DiscoveryWorker.Initialize();
            MetricsWorker.Initialize();
            SyncWorker.Initialize();

            // start workers
            Log.Debug("Starting agent worker threads");
            DiscoveryWorker.Start();
            MetricsWorker.Start();
            SyncWorker.Start();
        }
        public void Execute(IWorker[] workers, int runningSecs)
        {
            IAsyncResult[] ar = new IAsyncResult[workers.Length];
              int i = 0;
              foreach (IWorker w in workers) {
            w.WorkerID = i;
            ThreadStart t = new ThreadStart(w.DoWork);
            ar[i++] = t.BeginInvoke(null, null);
              }
              //for (int j = 0; j < runningSecs * 10; j++)
              //{
              //    Console.Write(".");
              //    Thread.Sleep(100);
              //}
              Thread.Sleep(runningSecs * 1000);
              Console.WriteLine();

              foreach (IWorker w in workers) {
            w.Running = false;
              }

              bool timeOut = false;
              foreach (IAsyncResult a in ar) {
              if (!a.IsCompleted)
              {
              if (!a.AsyncWaitHandle.WaitOne(1000))
                  timeOut = true;
              }
              }
              if (timeOut)
              Console.WriteLine("Timed Out!");
        }
Ejemplo n.º 6
0
 public AsyncTrashPurger(IWorker worker, ITrashHandler trash, IPersister persister, ISecurityManager security)
 {
     this.worker = worker;
     this.trash = trash;
     this.persister = persister;
     this.security = security;
 }
Ejemplo n.º 7
0
 public void setProperty(Identifier propName, IWorker worker)
 {
     throw new ClientException(
     String.Format(
         "attempted to set property '{0}' of a null value",
         propName));
 }
Ejemplo n.º 8
0
 public StockView(IWorker worker)
     : base(worker)
 {
     this.StockItemsCollection = new NotifiedObservableCollection<StockIngredientDTO>();
     this.RemovedStockItemsList = new List<StockIngredientDTO>();
     ResetIds();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// ServiceHandler Private Constructor
        /// </summary>
	    private ServiceHandler() 
        {
		
		    syncServiceWorker =  new SyncServiceWorker();
		    asyncServiceWorker = AsyncServiceWorker.GetInstance();
		
		    resourceManager = ResourceManager.GetInstance();
	    }
Ejemplo n.º 10
0
		public void Remove(IWorker worker)
		{
			lock (this.fSyncRoot)
			{
				worker.Done -= OnDone;
				base.Remove(worker);
			}
		}
Ejemplo n.º 11
0
		public void Add(IWorker worker)
		{
			lock (this.fSyncRoot)
			{
				worker.Done += OnDone;
				base.Add(worker);
			}
		}
Ejemplo n.º 12
0
 public ClientMainView(IWorker worker)
     : base(worker)
 {
     this.IngredientsCollection = new ObservableCollection<PizzaNetControls.IngredientsRow>();
     this.RecipesCollection = new ObservableCollection<PizzaNetControls.RecipeControl>();
     this.OrderedPizzasCollection = new ObservableCollection<IngredientsList>();
     this.Ingredients = new List<OrderIngredientDTO>();
 }
Ejemplo n.º 13
0
 public RedisBackend(IRedis redisClient, QueuedItem payload, Exception exception, IWorker worker, string queue)
 {
     RedisClient = redisClient;
     Payload = payload;
     Exception = exception;
     Worker = worker;
     Queue = queue;
 }
Ejemplo n.º 14
0
        protected BaseWorkerHost(IWorker worker)
        {
            worker.Require("worker");

            Worker = worker;

            Worker.ErrorOccurred += OnErrorOccurred;
            Worker.MessageOccurred += OnMessageOccurred;
        }
Ejemplo n.º 15
0
 public RecipiesView(IWorker worker)
     : base(worker)
 {
     this.IngredientsRowsCollection = new ObservableCollection<IngredientsRowWork>();
     this.RecipesCollection = new ObservableCollection<RecipeControl>();
     this.RemovedRecipes = new List<RecipeDTO>(5);
     SelectedRecipe = -1;
     Modified = false;
 }
Ejemplo n.º 16
0
 public static IWorker cast(IWorker source, IInterface face)
 {
     if( inheritsOrIs(source.face, face) )
     return castDown(source, face);
     source = source.owner.rootWorker;
     if( inheritsOrIs(source.face, face) )
     return castDown(source, face);
     throw new ClientException("the object does not implement this interface");
 }
Ejemplo n.º 17
0
 public Scheduler(IEngine engine, IPluginFinder plugins, IHeart heart, IWorker worker, IWebContext context, IErrorNotifier errorHandler)
 {
     this.engine = engine;
     actions = new List<ScheduledAction>(InstantiateActions(plugins));
     this.heart = heart;
     this.worker = worker;
     this.context = context;
     this.errorHandler = errorHandler;
 }
Ejemplo n.º 18
0
        public ParameterImpl(
	Direction direction, IType type,
	Identifier name, IWorker defaultValue )
        {
            _direction = direction;
            _type = type;
            _name = name;
            _defaultValue = defaultValue;
        }
Ejemplo n.º 19
0
		internal int RegisterRequest (IWorker worker)
		{
			int result = worker.GetHashCode ();
			lock (requests) {
				requests [result] = worker;
			}

			return result;
		}
Ejemplo n.º 20
0
        public void Init()
        {
            _worker = Factory.Instance.CreateWorker();
            _worker.NewMessage += GetMessage;

            _worker.Init(Port);

            _worker.ErrorMessage += WorkerError;
        }
 public Job(JobFactory creator, IFailureService failureService, IWorker worker, QueuedItem item,
            string queue)
 {
     Creator = creator;
     FailureService = failureService;
     Worker = worker;
     Payload = item;
     Queue = queue;
 }
Ejemplo n.º 22
0
 public static IWorker castDown(IWorker source, IInterface face)
 {
     Debug.Assert(inheritsOrIs(source.face, face));
     if( source.face == face )
     return source;
     foreach( IWorker child in source.childWorkers )
     if( inheritsOrIs(child.face, face) )
         return castDown(child, face);
     throw new ClientException("the object does not implement this interface");
 }
Ejemplo n.º 23
0
        public void AddWorker(IWorker worker)
        {
            if (_isRootInstance)
            {
                Thread workerThread = new Thread(RunWorker);
                workerThread.Start(worker);

                _workerThreads.Add(workerThread);
            }
        }
		public ServiceWrapper(IWorker worker, string name = null)
		{
			if(worker == null)
				throw new ArgumentNullException("worker");

			_worker = worker;

			this.ServiceName = string.IsNullOrWhiteSpace(name) ? worker.Name : name.Trim();
			this.CanPauseAndContinue = worker.CanPauseAndContinue;
		}
Ejemplo n.º 25
0
 public MyOrdersView(IWorker worker)
     : base(worker)
 {
     this.OrdersCollection = new NotifiedObservableCollection<OrdersRow>();
     this.IngredientsCollection = new ObservableCollection<OrderIngredientDTO>();
     this.PizzasCollection = new ObservableCollection<PizzaRow>();
     OrdersRefresher = new BackgroundWorker();
     OrdersRefresher.DoWork+=OrdersRefresher_DoWork;
     OrdersRefresher.RunWorkerCompleted += OrdersRefresher_RunWorkerCompleted;
 }
Ejemplo n.º 26
0
        public void Add(IWorker worker)
        {
            if (_workers.Exists(o => o.Id == worker.Id))
            {
                throw new ArgumentException("Id already exists");
            }

            _statisticsCollector.RegisterWorker(worker);
            _workers.Add(worker);
        }
Ejemplo n.º 27
0
        public AsyncIndexer(IContentIndexer indexer, IPersister persister, IWorker worker, IErrorNotifier errors, DatabaseSection config)
        {
            RetryInterval = TimeSpan.FromMinutes(2);
            this.async = config.Search.AsyncIndexing;
            this.handleErrors = config.Search.HandleErrors;

            this.indexer = indexer;
            this.persister = persister;
            this.worker = worker;
            this.errors = errors;
        }
Ejemplo n.º 28
0
        public WorkerService(IWorker worker)
        {
            this.worker = worker;
            this.id = worker.GetId();

            manager = new WorkersManager();
            manager.AddOverseenWorker(new OverseenWorker(this, null)); // Adds himself as an available worker

            logger = new LoggerWrapper("WS" + id);
            logger.Log("Created a new WorkerService");
        }
Ejemplo n.º 29
0
 public void PrepareDocuments(IWorker worker)
 {
     int step = 0;
     foreach (var document in documents)
     {
         worker.ReportProgress(step, document.Name);
         Prepare(document);
         if (worker.IsCancelled)
             return;
         step++;
     }
 }
Ejemplo n.º 30
0
        public MessageBroker(IChannel channel, IWorker worker, IReceiver[] receivers, Configuration.HostSection config)
        {
            this.channel = channel;
            this.worker = worker;
            this.receivers = receivers.ToLookup(r => r.MessageType);

            this.Name = config.Messaging.SenderName;
            this.Enabled = config.Messaging.Enabled;
            this.Async = config.Messaging.Async;
            this.OnlyFromMachineNamed = config.Messaging.Targets.OnlyFromMachineNamed;
            this.SharedSecret = config.Messaging.Targets.SharedSecret;
            this.Targets = config.Messaging.Targets.AllElements.Select(te => new MessageTarget { Name = te.Name, Address = te.Address, ExceptFromMachineNamed = te.ExceptFromMachineNamed }).ToArray();
        }